Skip to content

Commit

Permalink
add license to all generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Martin committed Nov 20, 2012
1 parent f00d89f commit 5bfb0d5
Show file tree
Hide file tree
Showing 34 changed files with 667 additions and 185 deletions.
3 changes: 3 additions & 0 deletions infusionsoft-net.sln.ide/graph/infusionsoft-net.sln.ide
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution Format="0.0.0.3">
<Version>0001-01-01T00:00:00Z</Version>
</Solution>
15 changes: 14 additions & 1 deletion src/Generator/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
using System;
#region License

// Copyright (c) 2012, EventDay
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System;
using System.IO;

namespace Generator
Expand Down
13 changes: 13 additions & 0 deletions src/Generator/IServicePartGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#region License

// Copyright (c) 2012, EventDay
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System;
using System.CodeDom;

Expand Down
48 changes: 30 additions & 18 deletions src/Generator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
using System;
#region License

// Copyright (c) 2012, EventDay
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System;
using System.IO;
using InfusionSoft;

namespace Generator
{
class Program
{
namespace Generator
{
internal class Program
{
private const string Output = @"..\..\..\InfusionSoft";

[STAThread]
static void Main()

[STAThread]
private static void Main()
{
var assembly = typeof (IInfusionSoftConfiguration).Assembly;

var generator = new ServiceGenerator(assembly)
{
InterfaceDirectory = Path.Combine(Output, ".").Directory(),
WrapperDirectory = Path.Combine(Output, "Wrappers").Directory()
};
{
InterfaceDirectory = Path.Combine(Output, ".").Directory(),
WrapperDirectory = Path.Combine(Output, "Wrappers").Directory()
};

Service[] services = generator.Generate();

Console.Out.WriteLine("{0} services created", services.Length);

Console.Out.WriteLine("done");
Console.ReadKey();
}
Console.Out.WriteLine("done");
Console.ReadKey();
}
}
}

}
22 changes: 19 additions & 3 deletions src/Generator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
using System.Reflection;
using System.Runtime.CompilerServices;
#region License

// Copyright (c) 2012, EventDay
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("DatabaseDocumentationScraper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -17,9 +30,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("1309e639-4619-49c4-a357-5f28c216767a")]

// Version information for an assembly consists of the following four values:
Expand All @@ -32,5 +47,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
15 changes: 14 additions & 1 deletion src/Generator/Service.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
#region License

// Copyright (c) 2012, EventDay
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System;

namespace Generator
{
class Service
internal class Service
{
public Service(Type definitionType)
{
Expand Down
15 changes: 14 additions & 1 deletion src/Generator/ServiceFile.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
#region License

// Copyright (c) 2012, EventDay
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System.IO;

namespace Generator
{
class ServiceFile
internal class ServiceFile
{
public FileInfo File { get; set; }
public string Name { get; set; }
Expand Down
66 changes: 48 additions & 18 deletions src/Generator/ServiceGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#region License

// Copyright (c) 2012, EventDay
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
Expand All @@ -8,7 +21,7 @@

namespace Generator
{
class ServiceGenerator
internal class ServiceGenerator
{
private readonly Assembly _assembly;
private readonly Lazy<IEnumerable<Type>> _definitionTypes;
Expand All @@ -33,15 +46,18 @@ public Service[] Generate()
Init();

return _definitionTypes.Value.Select(type => new Service(type)
{
Interface = GeneratePart(type, InterfaceDirectory, _interfaceGenerator),
Wrapper = GeneratePart(type, WrapperDirectory, _wrapperGenerator)
}).ToArray();
{
Interface =
GeneratePart(type, InterfaceDirectory,
_interfaceGenerator),
Wrapper =
GeneratePart(type, WrapperDirectory, _wrapperGenerator)
}).ToArray();
}

private void Init()
{
if(InterfaceDirectory==null || WrapperDirectory == null)
if (InterfaceDirectory == null || WrapperDirectory == null)
throw new NotSupportedException("Must set InterfaceDirectory and WrapperDirectory properties.");

if (Directory.Exists(InterfaceDirectory.FullName) == false)
Expand All @@ -59,31 +75,45 @@ private void Init()
private ServiceFile GeneratePart(Type type, DirectoryInfo directory, IServicePartGenerator generator)
{
var provider = CodeDomProvider.CreateProvider("CSharp");
var options = new CodeGeneratorOptions
{
BracingStyle = "C"
};

var options = new CodeGeneratorOptions
{
BracingStyle = "C"
};

string name;
var unit = generator.Generate(type, out name);
var fileName = Path.Combine(directory.FullName, string.Format("{0}.cs", name));
using(var stream = File.Create(fileName))
using(var writer = new StreamWriter(stream))

using (var stream = File.Create(fileName))
using (var writer = new StreamWriter(stream))
{
writer.WriteLine("#region License");
writer.WriteLine();
writer.WriteLine("// Copyright (c) 2012, EventDay");
writer.WriteLine("// All rights reserved.");
writer.WriteLine("// ");
writer.WriteLine("// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:");
writer.WriteLine("// ");
writer.WriteLine("// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.");
writer.WriteLine("// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.");
writer.WriteLine("// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.");
writer.WriteLine();
writer.WriteLine("#endregion");

provider.GenerateCodeFromCompileUnit(unit, writer, options);
}

return new ServiceFile
{
File = new FileInfo(fileName),
Name = name
};
{
File = new FileInfo(fileName),
Name = name
};
}

private IEnumerable<Type> LoadDefinitions()
{
var type = typeof(IServiceDefinition);
var type = typeof (IServiceDefinition);
var types = _assembly.GetTypes().Where(type.IsAssignableFrom);
return types.Where(t => t != type);
}
Expand Down
Loading

0 comments on commit 5bfb0d5

Please sign in to comment.