Add() публичный Метод

public Add ( CodeNamespace value ) : int
value CodeNamespace
Результат int
Пример #1
0
		public void Constructor1_Deny_Unrestricted ()
		{
			CodeNamespaceCollection coll = new CodeNamespaceCollection (array);
			coll.CopyTo (array, 0);
			Assert.AreEqual (1, coll.Add (cn), "Add");
			Assert.AreSame (cn, coll[0], "this[int]");
			coll.AddRange (array);
			coll.AddRange (coll);
			Assert.IsTrue (coll.Contains (cn), "Contains");
			Assert.AreEqual (0, coll.IndexOf (cn), "IndexOf");
			coll.Insert (0, cn);
			coll.Remove (cn);
		}
 private CodeTypeDeclaration CreateOrGetServiceDeclaration(Activity rootActivity, CodeNamespaceCollection codeNamespaceCollection)
 {
     string namespaceName = "";
     CodeNamespace webServiceCodeNamespace = null;
     string fullName = rootActivity.GetType().FullName;
     CodeTypeDeclaration webserviceCodeTypeDeclaration = null;
     if (rootActivity.GetType().FullName.IndexOf(".") != -1)
     {
         namespaceName = rootActivity.GetType().FullName.Substring(0, rootActivity.GetType().FullName.LastIndexOf('.'));
     }
     foreach (CodeNamespace namespace3 in codeNamespaceCollection)
     {
         if (namespace3.Name == namespaceName)
         {
             webServiceCodeNamespace = namespace3;
             break;
         }
     }
     if (webServiceCodeNamespace == null)
     {
         webServiceCodeNamespace = this.GetWebServiceCodeNamespace(namespaceName);
         codeNamespaceCollection.Add(webServiceCodeNamespace);
     }
     string str3 = fullName.Substring(fullName.LastIndexOf('.') + 1) + "_WebService";
     foreach (CodeTypeDeclaration declaration2 in webServiceCodeNamespace.Types)
     {
         if (declaration2.Name == str3)
         {
             webserviceCodeTypeDeclaration = declaration2;
             break;
         }
     }
     if (webserviceCodeTypeDeclaration == null)
     {
         webserviceCodeTypeDeclaration = this.GetWebserviceCodeTypeDeclaration(fullName.Substring(fullName.LastIndexOf('.') + 1));
         webServiceCodeNamespace.Types.Add(webserviceCodeTypeDeclaration);
         webServiceCodeNamespace.Imports.Add(new CodeNamespaceImport("System"));
         webServiceCodeNamespace.Imports.Add(new CodeNamespaceImport("System.Web"));
         webServiceCodeNamespace.Imports.Add(new CodeNamespaceImport("System.Web.Services"));
         webServiceCodeNamespace.Imports.Add(new CodeNamespaceImport("System.Web.Services.Protocols"));
         webServiceCodeNamespace.Imports.Add(new CodeNamespaceImport("System.Workflow.Runtime.Hosting"));
         webServiceCodeNamespace.Imports.Add(new CodeNamespaceImport("System.Workflow.Activities"));
     }
     return webserviceCodeTypeDeclaration;
 }
Пример #3
0
        public CodeNamespaceCollection Build(JavaActivity activity)
        {
            var javaNamespace = new CodeNamespace(activity.PackageName);

            // Generate the Service
            javaNamespace.Imports.AddRange(this.GenerateImports());
            var javaClass = this.GenerateClass(activity);
            javaClass.Members.Add(this.GenerateInvokeMethod());
            javaNamespace.Types.Add(javaClass);

            var codeNameSpaces =  new CodeNamespaceCollection {javaNamespace};

            // Generate the corresponding interface
            if (ConfigurationApp.GetProperty ("IsJavaInterfaceAlreadyGenerated") != "true")
            {
                //TODO : Refactor because it's a bit dirty
                var javaServiceInterfaceNameSpace = InterfaceExtractorFromClass.Extract(javaClass, TargetAppNameSpaceService.javaToolsNameSpace);
                javaServiceInterfaceNameSpace.Types[0].Name = "IJavaActivtyService";
                codeNameSpaces.Add(javaServiceInterfaceNameSpace);
                ConfigurationApp.SaveProperty("IsJavaInterfaceAlreadyGenerated", "true");
            }

            return codeNameSpaces;
        }
Пример #4
0
        /// <summary>
        /// Used when adding a new type to a code namespace. Method looks for a matching namespace
        /// in the namespaces collection or adds a new one if it does not exist.
        /// </summary>
        /// <param name="codeNamespaces">A collection of code namespaces.</param>
        /// <param name="namespaceName">A string containig the name of the namespace to find or add.</param>
        /// <returns>A code namespace object containing a new code namespace or an existing namespace.</returns>
        internal static CodeNamespace GetDotNetNamespace(CodeNamespaceCollection codeNamespaces, string namespaceName)
        {
            CodeNamespace dotNetNamespace = null;
            string dotNetNamespaceName = GenerateDotNetNamespace(namespaceName);

            // Search for the namespace
            foreach (CodeNamespace codeNs in codeNamespaces)
            {
                if (codeNs.Name == dotNetNamespaceName)
                    return codeNs;
            }

            // If namespace was not found create on and add it to the namespaces collection
            dotNetNamespace = new CodeNamespace(dotNetNamespaceName);
            codeNamespaces.Add(dotNetNamespace);

            s_namespaceToDotNetNamespace[dotNetNamespace] = namespaceName;

            return dotNetNamespace;
        }
 CodeNamespaceCollection GenerateProcessVariablesNamespaces(TibcoBWProcess tibcoBwProcessToGenerate)
 {
     CodeNamespaceCollection processVariableNameNamespaces = new CodeNamespaceCollection();
     if (tibcoBwProcessToGenerate.ProcessVariables != null)
     {
         foreach (var item in tibcoBwProcessToGenerate.ProcessVariables)
         {
             if (!IsBasicType(item.Parameter.Type))
             {
                 processVariableNameNamespaces.Add(this.xsdClassGenerator.Build(item.ObjectXNodes, tibcoBwProcessToGenerate.NameSpace));
             }
         }
     }
     return processVariableNameNamespaces;
 }
        internal static CodeNamespaceCollection GenerateCodeFromXomlDocument(Activity rootActivity, string filePath, string rootNamespace, SupportedLanguages language, IServiceProvider serviceProvider)
        {
            CodeNamespaceCollection codeNamespaces = new CodeNamespaceCollection();
            CodeDomProvider codeDomProvider = CompilerHelpers.GetCodeDomProvider(language);

            // generate activity class
            string activityFullClassName = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
            CodeTypeDeclaration activityTypeDeclaration = null;
            if (codeDomProvider != null && !string.IsNullOrEmpty(activityFullClassName))
            {
                // get class and namespace names
                string activityNamespaceName, activityClassName;
                Helpers.GetNamespaceAndClassName(activityFullClassName, out activityNamespaceName, out activityClassName);
                if (codeDomProvider.IsValidIdentifier(activityClassName))
                {
                    DesignerSerializationManager designerSerializationManager = new DesignerSerializationManager(serviceProvider);
                    using (designerSerializationManager.CreateSession())
                    {
                        ActivityCodeDomSerializationManager codeDomSerializationManager = new ActivityCodeDomSerializationManager(designerSerializationManager);
                        TypeCodeDomSerializer typeCodeDomSerializer = codeDomSerializationManager.GetSerializer(rootActivity.GetType(), typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer;

                        // get all activities
                        bool generateCode = true;

                        ArrayList allActivities = new ArrayList();
                        allActivities.Add(rootActivity);
                        if (rootActivity is CompositeActivity)
                        {
                            foreach (Activity activity in Helpers.GetNestedActivities((CompositeActivity)rootActivity))
                            {
                                if (Helpers.IsActivityLocked(activity))
                                    continue;
                                if (codeDomProvider.IsValidIdentifier(codeDomSerializationManager.GetName(activity)))
                                {
                                    // WinOE Bug 14561.  This is to fix a performance problem.  When an activity is added to the activity
                                    // tree at the runtime, it's much faster if the ID of the activity is already set.  The code that
                                    // the CodeDomSerializer generates will add the activity first before it sets the ID for the child
                                    // activity.  We can change that order by always serializing the children first.  Therefore, we 
                                    // construct a list where we guarantee that the child will be serialized before its parent.
                                    allActivities.Insert(0, activity);
                                }
                                else
                                {
                                    generateCode = false;
                                    break;
                                }
                            }
                        }

                        if (generateCode)
                        {
                            // Work around!! TypeCodeDomSerializer checks that root component has a site or not, otherwise it
                            // does not serialize it look at ComponentTypeCodeDomSerializer.cs
                            DummySite dummySite = new DummySite();
                            foreach (Activity nestedActivity in allActivities)
                                ((IComponent)nestedActivity).Site = dummySite;
                            ((IComponent)rootActivity).Site = dummySite;

                            // create activity partial class
                            activityTypeDeclaration = typeCodeDomSerializer.Serialize(codeDomSerializationManager, rootActivity, allActivities);
                            activityTypeDeclaration.IsPartial = true;

                            // add checksum attribute
                            if (filePath != null && filePath.Length > 0)
                            {
                                MD5 md5 = new MD5CryptoServiceProvider();
                                byte[] checksumBytes = null;
                                using (StreamReader streamReader = new StreamReader(filePath))
                                    checksumBytes = md5.ComputeHash(streamReader.BaseStream);
                                string checksum = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}", new object[] { checksumBytes[0].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[1].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[2].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[3].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[4].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[5].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[6].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[7].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[8].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[9].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[10].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[11].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[12].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[13].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[14].ToString("X2", CultureInfo.InvariantCulture), checksumBytes[15].ToString("X2", CultureInfo.InvariantCulture) });
                                CodeAttributeDeclaration xomlSourceAttribute = new CodeAttributeDeclaration(typeof(WorkflowMarkupSourceAttribute).FullName);
                                xomlSourceAttribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(filePath)));
                                xomlSourceAttribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(checksum)));
                                activityTypeDeclaration.CustomAttributes.Add(xomlSourceAttribute);
                            }

                            // create a new namespace and add activity class into that
                            CodeNamespace activityCodeNamespace = new CodeNamespace(activityNamespaceName);
                            activityCodeNamespace.Types.Add(activityTypeDeclaration);
                            codeNamespaces.Add(activityCodeNamespace);
                        }
                    }
                }
            }

            // generate code for x:Code
            if (activityTypeDeclaration != null)
            {
                Queue activitiesQueue = new Queue(new object[] { rootActivity });
                while (activitiesQueue.Count > 0)
                {
                    Activity activity = (Activity)activitiesQueue.Dequeue();
                    if (Helpers.IsActivityLocked(activity))
                        continue;

                    Queue childActivities = new Queue(new object[] { activity });
                    while (childActivities.Count > 0)
                    {
                        Activity childActivity = (Activity)childActivities.Dequeue();
                        if (childActivity is CompositeActivity)
                        {
                            foreach (Activity nestedChildActivity in ((CompositeActivity)childActivity).Activities)
                            {
                                childActivities.Enqueue(nestedChildActivity);
                            }
                        }

                        // generate x:Code
                        CodeTypeMemberCollection codeSegments = childActivity.GetValue(WorkflowMarkupSerializer.XCodeProperty) as CodeTypeMemberCollection;
                        if (codeSegments != null)
                        {
                            foreach (CodeSnippetTypeMember codeSegmentMember in codeSegments)
                                activityTypeDeclaration.Members.Add(codeSegmentMember);
                        }
                    }
                }

                if (language == SupportedLanguages.CSharp)
                    activityTypeDeclaration.LinePragma = new CodeLinePragma((string)rootActivity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int)rootActivity.GetValue(ActivityMarkupSerializer.StartLineProperty), 1));

                //Now make sure we that we also emit line pragma around the constructor
                CodeConstructor constructor = null;
                CodeMemberMethod method = null;
                foreach (CodeTypeMember typeMember in activityTypeDeclaration.Members)
                {
                    if (constructor == null && typeMember is CodeConstructor)
                        constructor = typeMember as CodeConstructor;

                    if (method == null && typeMember is CodeMemberMethod && typeMember.Name.Equals("InitializeComponent", StringComparison.Ordinal))
                        method = typeMember as CodeMemberMethod;

                    if (constructor != null && method != null)
                        break;
                }

                if (constructor != null)
                    constructor.LinePragma = new CodeLinePragma((string)rootActivity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int)rootActivity.GetValue(ActivityMarkupSerializer.StartLineProperty), 1));

                if (method != null && language == SupportedLanguages.CSharp)
                    method.LinePragma = new CodeLinePragma((string)rootActivity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int)rootActivity.GetValue(ActivityMarkupSerializer.StartLineProperty), 1));
            }

            // generate mappings
            List<String> clrNamespaces = rootActivity.GetValue(WorkflowMarkupSerializer.ClrNamespacesProperty) as List<String>;
            if (clrNamespaces != null)
            {
                // foreach namespace add these mappings
                foreach (CodeNamespace codeNamespace in codeNamespaces)
                {
                    foreach (string clrNamespace in clrNamespaces)
                    {
                        if (!String.IsNullOrEmpty(clrNamespace))
                        {
                            CodeNamespaceImport codeNamespaceImport = new CodeNamespaceImport(clrNamespace);
                            codeNamespaceImport.LinePragma = new CodeLinePragma((string)rootActivity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int)rootActivity.GetValue(ActivityMarkupSerializer.StartLineProperty), 1));
                            codeNamespace.Imports.Add(codeNamespaceImport);
                        }
                    }
                }
            }
            // return namespaces
            return codeNamespaces;
        }
Пример #7
0
 protected void Rewrite(CodeNamespaceCollection target, CodeNamespaceCollection source, ref bool didRewrite)
 {
     foreach (CodeNamespace item in source)
     {
         target.Add(this.Rewrite(item, ref didRewrite));
     }
 }
 internal static CodeNamespaceCollection GenerateCodeFromXomlDocument(Activity rootActivity, string filePath, string rootNamespace, SupportedLanguages language, IServiceProvider serviceProvider)
 {
     CodeNamespaceCollection namespaces = new CodeNamespaceCollection();
     CodeDomProvider codeDomProvider = CompilerHelpers.GetCodeDomProvider(language);
     string str = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
     CodeTypeDeclaration declaration = null;
     if ((codeDomProvider != null) && !string.IsNullOrEmpty(str))
     {
         string str2;
         string str3;
         Helpers.GetNamespaceAndClassName(str, out str2, out str3);
         if (codeDomProvider.IsValidIdentifier(str3))
         {
             DesignerSerializationManager manager = new DesignerSerializationManager(serviceProvider);
             using (manager.CreateSession())
             {
                 ActivityCodeDomSerializationManager manager2 = new ActivityCodeDomSerializationManager(manager);
                 TypeCodeDomSerializer serializer = manager2.GetSerializer(rootActivity.GetType(), typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer;
                 bool flag = true;
                 ArrayList list = new ArrayList();
                 list.Add(rootActivity);
                 if (rootActivity is CompositeActivity)
                 {
                     foreach (Activity activity in Helpers.GetNestedActivities((CompositeActivity) rootActivity))
                     {
                         if (!Helpers.IsActivityLocked(activity))
                         {
                             if (codeDomProvider.IsValidIdentifier(manager2.GetName(activity)))
                             {
                                 list.Insert(0, activity);
                             }
                             else
                             {
                                 flag = false;
                                 break;
                             }
                         }
                     }
                 }
                 if (flag)
                 {
                     DummySite site = new DummySite();
                     foreach (Activity activity2 in list)
                     {
                         activity2.Site = site;
                     }
                     rootActivity.Site = site;
                     declaration = serializer.Serialize(manager2, rootActivity, list);
                     declaration.IsPartial = true;
                     if ((filePath != null) && (filePath.Length > 0))
                     {
                         MD5 md = new MD5CryptoServiceProvider();
                         byte[] buffer = null;
                         using (StreamReader reader = new StreamReader(filePath))
                         {
                             buffer = md.ComputeHash(reader.BaseStream);
                         }
                         string str4 = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}", new object[] { buffer[0].ToString("X2", CultureInfo.InvariantCulture), buffer[1].ToString("X2", CultureInfo.InvariantCulture), buffer[2].ToString("X2", CultureInfo.InvariantCulture), buffer[3].ToString("X2", CultureInfo.InvariantCulture), buffer[4].ToString("X2", CultureInfo.InvariantCulture), buffer[5].ToString("X2", CultureInfo.InvariantCulture), buffer[6].ToString("X2", CultureInfo.InvariantCulture), buffer[7].ToString("X2", CultureInfo.InvariantCulture), buffer[8].ToString("X2", CultureInfo.InvariantCulture), buffer[9].ToString("X2", CultureInfo.InvariantCulture), buffer[10].ToString("X2", CultureInfo.InvariantCulture), buffer[11].ToString("X2", CultureInfo.InvariantCulture), buffer[12].ToString("X2", CultureInfo.InvariantCulture), buffer[13].ToString("X2", CultureInfo.InvariantCulture), buffer[14].ToString("X2", CultureInfo.InvariantCulture), buffer[15].ToString("X2", CultureInfo.InvariantCulture) });
                         CodeAttributeDeclaration declaration2 = new CodeAttributeDeclaration(typeof(WorkflowMarkupSourceAttribute).FullName);
                         declaration2.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(filePath)));
                         declaration2.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(str4)));
                         declaration.CustomAttributes.Add(declaration2);
                     }
                     CodeNamespace namespace2 = new CodeNamespace(str2);
                     namespace2.Types.Add(declaration);
                     namespaces.Add(namespace2);
                 }
             }
         }
     }
     if (declaration != null)
     {
         Queue queue = new Queue(new object[] { rootActivity });
         while (queue.Count > 0)
         {
             Activity activity3 = (Activity) queue.Dequeue();
             if (!Helpers.IsActivityLocked(activity3))
             {
                 Queue queue2 = new Queue(new object[] { activity3 });
                 while (queue2.Count > 0)
                 {
                     Activity activity4 = (Activity) queue2.Dequeue();
                     if (activity4 is CompositeActivity)
                     {
                         foreach (Activity activity5 in ((CompositeActivity) activity4).Activities)
                         {
                             queue2.Enqueue(activity5);
                         }
                     }
                     CodeTypeMemberCollection members = activity4.GetValue(WorkflowMarkupSerializer.XCodeProperty) as CodeTypeMemberCollection;
                     if (members != null)
                     {
                         foreach (CodeSnippetTypeMember member in members)
                         {
                             declaration.Members.Add(member);
                         }
                     }
                 }
             }
         }
         if (language == SupportedLanguages.CSharp)
         {
             declaration.LinePragma = new CodeLinePragma((string) rootActivity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int) rootActivity.GetValue(ActivityMarkupSerializer.StartLineProperty), 1));
         }
         CodeConstructor constructor = null;
         CodeMemberMethod method = null;
         foreach (CodeTypeMember member2 in declaration.Members)
         {
             if ((constructor == null) && (member2 is CodeConstructor))
             {
                 constructor = member2 as CodeConstructor;
             }
             if (((method == null) && (member2 is CodeMemberMethod)) && member2.Name.Equals("InitializeComponent", StringComparison.Ordinal))
             {
                 method = member2 as CodeMemberMethod;
             }
             if ((constructor != null) && (method != null))
             {
                 break;
             }
         }
         if (constructor != null)
         {
             constructor.LinePragma = new CodeLinePragma((string) rootActivity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int) rootActivity.GetValue(ActivityMarkupSerializer.StartLineProperty), 1));
         }
         if ((method != null) && (language == SupportedLanguages.CSharp))
         {
             method.LinePragma = new CodeLinePragma((string) rootActivity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int) rootActivity.GetValue(ActivityMarkupSerializer.StartLineProperty), 1));
         }
     }
     List<string> list2 = rootActivity.GetValue(WorkflowMarkupSerializer.ClrNamespacesProperty) as List<string>;
     if (list2 != null)
     {
         foreach (CodeNamespace namespace3 in namespaces)
         {
             foreach (string str5 in list2)
             {
                 if (!string.IsNullOrEmpty(str5))
                 {
                     CodeNamespaceImport import = new CodeNamespaceImport(str5) {
                         LinePragma = new CodeLinePragma((string) rootActivity.GetValue(ActivityCodeDomSerializer.MarkupFileNameProperty), Math.Max((int) rootActivity.GetValue(ActivityMarkupSerializer.StartLineProperty), 1))
                     };
                     namespace3.Imports.Add(import);
                 }
             }
         }
     }
     return namespaces;
 }
        public Type[] Generate(IEnumerable<XPathModuleInfo> modules)
        {
            bool debuggerIsAttached = Debugger.IsAttached;

             var generatedTypeNames = new List<string>();

             var compilerParams = new CompilerParameters {
            GenerateInMemory = !debuggerIsAttached,
            ReferencedAssemblies = {
               // current assembly
               typeof(IntegratedExtensionFunctionGenerator).Assembly.Location,

               // Saxon.Api
               typeof(ExtensionFunctionDefinition).Assembly.Location,

               // System
               typeof(Uri).Assembly.Location,

               // System.Core
               typeof(Enumerable).Assembly.Location,
            }
             };

             var namespaces = new CodeNamespaceCollection();

             foreach (XPathModuleInfo module in modules) {

            string[] functionDefTypeNames;

            namespaces.Add(GenerateModuleTypes(module, out functionDefTypeNames));
            generatedTypeNames.AddRange(functionDefTypeNames);

            AddAssemblyReference(compilerParams, module.Type.Assembly);

            foreach (XPathFunctionInfo function in module.Functions) {
               AddAssemblyReference(compilerParams, function.ReturnType.ClrType.Assembly);

               foreach (XPathVariableInfo param in function.Parameters) {
                  AddAssemblyReference(compilerParams, param.Type.ClrType.Assembly);
               }
            }
             }

             var compileUnit = new CodeCompileUnit();
             compileUnit.Namespaces.AddRange(namespaces);

             CompilerResults result = this.provider.CompileAssemblyFromDom(compilerParams, compileUnit);

             CompilerError firstError = result.Errors.Cast<CompilerError>().FirstOrDefault(e => !e.IsWarning);

             if (firstError != null) {

            using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) {

               provider.GenerateCodeFromCompileUnit(compileUnit, stringWriter, null);

               if (debuggerIsAttached) {
                  Debugger.Log(0, Debugger.DefaultCategory, "Integrated extension function generation error:" + Environment.NewLine);
                  Debugger.Log(0, Debugger.DefaultCategory, stringWriter.ToString());
               }
            }

            throw new ArgumentException(firstError.ErrorText, "modules");
             }

             if (debuggerIsAttached) {
            Debugger.Log(0, Debugger.DefaultCategory, "Integrated extension function(s) generated " + result.PathToAssembly + Environment.NewLine);
             }

             return generatedTypeNames
            .Select(n => result.CompiledAssembly.GetType(n, throwOnError: true))
            .ToArray();
        }
Пример #10
0
		public void Constructor2 ()
		{
			CodeNamespace ns1 = new CodeNamespace ();
			CodeNamespace ns2 = new CodeNamespace ();

			CodeNamespaceCollection c = new CodeNamespaceCollection ();
			c.Add (ns1);
			c.Add (ns2);

			CodeNamespaceCollection coll = new CodeNamespaceCollection (c);
			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (ns1), "#2");
			Assert.AreEqual (1, coll.IndexOf (ns2), "#3");
		}
Пример #11
0
		public void Remove ()
		{
			CodeNamespace cns1 = new CodeNamespace ();
			CodeNamespace cns2 = new CodeNamespace ();

			CodeNamespaceCollection coll = new CodeNamespaceCollection ();
			coll.Add (cns1);
			coll.Add (cns2);
			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (cns1), "#2");
			Assert.AreEqual (1, coll.IndexOf (cns2), "#3");
			coll.Remove (cns1);
			Assert.AreEqual (1, coll.Count, "#4");
			Assert.AreEqual (-1, coll.IndexOf (cns1), "#5");
			Assert.AreEqual (0, coll.IndexOf (cns2), "#6");
		}
Пример #12
0
		public void AddRange_Self ()
		{
			CodeNamespaceCollection coll = new CodeNamespaceCollection ();
			coll.Add (new CodeNamespace ());
			Assert.AreEqual (1, coll.Count, "#1");
			coll.AddRange (coll);
			Assert.AreEqual (2, coll.Count, "#2");
		}
Пример #13
0
		public void AddRange ()
		{
			CodeNamespace ns1 = new CodeNamespace ();
			CodeNamespace ns2 = new CodeNamespace ();
			CodeNamespace ns3 = new CodeNamespace ();

			CodeNamespaceCollection coll1 = new CodeNamespaceCollection ();
			coll1.Add (ns1);
			coll1.Add (ns2);

			CodeNamespaceCollection coll2 = new CodeNamespaceCollection ();
			coll2.Add (ns3);
			coll2.AddRange (coll1);
			Assert.AreEqual (3, coll2.Count, "#1");
			Assert.AreEqual (1, coll2.IndexOf (ns1), "#2");
			Assert.AreEqual (2, coll2.IndexOf (ns2), "#3");
			Assert.AreEqual (0, coll2.IndexOf (ns3), "#4");

			CodeNamespaceCollection coll3 = new CodeNamespaceCollection ();
			coll3.Add (ns3);
			coll3.AddRange (new CodeNamespace[] { ns1, ns2 });
			Assert.AreEqual (3, coll2.Count, "#5");
			Assert.AreEqual (1, coll2.IndexOf (ns1), "#6");
			Assert.AreEqual (2, coll2.IndexOf (ns2), "#7");
			Assert.AreEqual (0, coll2.IndexOf (ns3), "#8");
		}
Пример #14
0
		public void Insert ()
		{
			CodeNamespace ns1 = new CodeNamespace ();
			CodeNamespace ns2 = new CodeNamespace ();

			CodeNamespaceCollection coll = new CodeNamespaceCollection ();
			coll.Add (ns1);
			Assert.AreEqual (1, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (ns1), "#2");
			coll.Insert (0, ns2);
			Assert.AreEqual (2, coll.Count, "#3");
			Assert.AreEqual (1, coll.IndexOf (ns1), "#4");
			Assert.AreEqual (0, coll.IndexOf (ns2), "#5");
		}
Пример #15
0
		public void Add_Null () {
			CodeNamespaceCollection coll = new CodeNamespaceCollection ();
			coll.Add ((CodeNamespace) null);
		}