当前位置: 首页>>代码示例>>C#>>正文


C# CodeIdentifiers.MakeUnique方法代码示例

本文整理汇总了C#中System.Xml.Serialization.CodeIdentifiers.MakeUnique方法的典型用法代码示例。如果您正苦于以下问题:C# CodeIdentifiers.MakeUnique方法的具体用法?C# CodeIdentifiers.MakeUnique怎么用?C# CodeIdentifiers.MakeUnique使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Serialization.CodeIdentifiers的用法示例。


在下文中一共展示了CodeIdentifiers.MakeUnique方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateComponentCode

        static void GenerateComponentCode(object component, SteticCompilationUnit globalUnit, CodeNamespace globalNs, CodeExpression cobj, CodeStatementCollection statements, CodeTypeDeclaration globalType, GenerationOptions options, List<SteticCompilationUnit> units, CodeIdentifiers ids, ArrayList warnings)
        {
            Gtk.Widget widget = component as Gtk.Widget;
            Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup (widget);
            Wrapper.ActionGroup agroup = component as Wrapper.ActionGroup;

            string name = widget != null ? widget.Name : agroup.Name;
            string internalClassName = ids.MakeUnique (CodeIdentifier.MakeValid (name));

            string typeName = widget != null ? wwidget.WrappedTypeName : "Gtk.ActionGroup";
            // Create the build method for the top level

            CodeMemberMethod met;
            met = GetBuildMethod (name, internalClassName, typeName, globalUnit, options, units);

            // Generate the build code

            CodeVariableDeclarationStatement varDecHash = new CodeVariableDeclarationStatement (typeof(System.Collections.Hashtable), "bindings");
            met.Statements.Add (varDecHash);
            varDecHash.InitExpression = new CodeObjectCreateExpression (
                typeof(System.Collections.Hashtable),
                new CodeExpression [0]
            );

            CodeVariableReferenceExpression targetObjectVar = new CodeVariableReferenceExpression ("cobj");
            Stetic.WidgetMap map;

            if (widget != null) {
                map = Stetic.CodeGenerator.GenerateCreationCode (globalNs, globalType, widget, targetObjectVar, met.Statements, options, warnings);
                CodeGenerator.BindSignalHandlers (targetObjectVar, wwidget, map, met.Statements, options);
            } else {
                map = Stetic.CodeGenerator.GenerateCreationCode (globalNs, globalType, agroup, targetObjectVar, met.Statements, options, warnings);
                foreach (Wrapper.Action ac in agroup.Actions)
                    CodeGenerator.BindSignalHandlers (targetObjectVar, ac, map, met.Statements, options);
            }

            GenerateBindFieldCode (met.Statements, cobj);

            // Add a method call to the build method

            statements.Add (
                new CodeMethodInvokeExpression (
                    new CodeTypeReferenceExpression (options.GlobalNamespace + ".SteticGenerated." + internalClassName),
                    "Build",
                    new CodeCastExpression (typeName, cobj)
                )
            );
        }
开发者ID:mono,项目名称:stetic,代码行数:48,代码来源:CodeGeneratorInternalClass.cs

示例2: GenerateMethod


//.........这里部分代码省略.........
                 parameterAttributes[index] = new CodeAttributeDeclarationCollection();
                 this.xmlExporter.AddMappingMetadata(parameterAttributes[index], parameter2.mapping, ns, parameter2.specifiedName != (parameter2.mapping.MemberName + "Specified"));
                 parameterAttributes[index].Add(declaration);
             }
         }
         if ((parameterAttributes[index].Count > 0) && !base.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.ParameterAttributes))
         {
             base.UnsupportedOperationWarning(System.Web.Services.Res.GetString("CodeGenSupportParameterAttributes", new object[] { base.ServiceImporter.CodeGenerator.GetType().Name }));
             return null;
         }
         index++;
     }
     CodeFlags[] codeFlags = SoapParameter.GetCodeFlags(parameters.Parameters, parameters.CheckSpecifiedCount);
     string[] parameterTypeNames = SoapParameter.GetTypeFullNames(parameters.Parameters, parameters.CheckSpecifiedCount, base.ServiceImporter.CodeGenerator);
     string returnTypeName = (parameters.Return == null) ? typeof(void).FullName : WebCodeGenerator.FullTypeName(parameters.Return, base.ServiceImporter.CodeGenerator);
     CodeMemberMethod codeMethod = WebCodeGenerator.AddMethod(base.CodeTypeDeclaration, str3, codeFlags, parameterTypeNames, SoapParameter.GetNames(parameters.Parameters, parameters.CheckSpecifiedCount), parameterAttributes, returnTypeName, metadata, CodeFlags.IsPublic | ((base.Style == ServiceDescriptionImportStyle.Client) ? ((CodeFlags) 0) : CodeFlags.IsAbstract));
     codeMethod.Comments.Add(new CodeCommentStatement(System.Web.Services.Res.GetString("CodeRemarks"), true));
     if (parameters.Return != null)
     {
         if (soapBodyBinding.Use == SoapBindingUse.Encoded)
         {
             this.soapExporter.AddMappingMetadata(codeMethod.ReturnTypeCustomAttributes, parameters.Return, parameters.Return.ElementName != (identifier + "Result"));
         }
         else
         {
             this.xmlExporter.AddMappingMetadata(codeMethod.ReturnTypeCustomAttributes, parameters.Return, response.Namespace, parameters.Return.ElementName != (identifier + "Result"));
         }
         if ((codeMethod.ReturnTypeCustomAttributes.Count != 0) && !base.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.ReturnTypeAttributes))
         {
             base.UnsupportedOperationWarning(System.Web.Services.Res.GetString("CodeGenSupportReturnTypeAttributes", new object[] { base.ServiceImporter.CodeGenerator.GetType().Name }));
             return null;
         }
     }
     string resultsName = identifiers.MakeUnique("results");
     if (base.Style == ServiceDescriptionImportStyle.Client)
     {
         bool flag6 = (base.ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateOldAsync) != CodeGenerationOptions.None;
         bool flag7 = (((base.ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateNewAsync) != CodeGenerationOptions.None) && base.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareEvents)) && base.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareDelegates);
         CodeExpression[] invokeParams = new CodeExpression[2];
         this.CreateInvokeParams(invokeParams, identifier, parameters.InParameters, parameters.InCheckSpecifiedCount);
         CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "Invoke", invokeParams);
         this.WriteReturnMappings(codeMethod, invoke, parameters, resultsName);
         if (flag6)
         {
             int num2 = parameters.InParameters.Count + parameters.InCheckSpecifiedCount;
             string[] typeFullNames = new string[num2 + 2];
             SoapParameter.GetTypeFullNames(parameters.InParameters, typeFullNames, 0, parameters.InCheckSpecifiedCount, base.ServiceImporter.CodeGenerator);
             typeFullNames[num2] = typeof(AsyncCallback).FullName;
             typeFullNames[num2 + 1] = typeof(object).FullName;
             string[] strArray4 = new string[num2 + 2];
             SoapParameter.GetNames(parameters.InParameters, strArray4, 0, parameters.InCheckSpecifiedCount);
             strArray4[num2] = "callback";
             strArray4[num2 + 1] = "asyncState";
             CodeFlags[] parameterFlags = new CodeFlags[num2 + 2];
             CodeMemberMethod method2 = WebCodeGenerator.AddMethod(base.CodeTypeDeclaration, "Begin" + identifier, parameterFlags, typeFullNames, strArray4, typeof(IAsyncResult).FullName, null, CodeFlags.IsPublic);
             method2.Comments.Add(new CodeCommentStatement(System.Web.Services.Res.GetString("CodeRemarks"), true));
             invokeParams = new CodeExpression[4];
             this.CreateInvokeParams(invokeParams, identifier, parameters.InParameters, parameters.InCheckSpecifiedCount);
             invokeParams[2] = new CodeArgumentReferenceExpression("callback");
             invokeParams[3] = new CodeArgumentReferenceExpression("asyncState");
             invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "BeginInvoke", invokeParams);
             method2.Statements.Add(new CodeMethodReturnStatement(invoke));
             int num3 = parameters.OutParameters.Count + parameters.OutCheckSpecifiedCount;
             string[] strArray5 = new string[num3 + 1];
             SoapParameter.GetTypeFullNames(parameters.OutParameters, strArray5, 1, parameters.OutCheckSpecifiedCount, base.ServiceImporter.CodeGenerator);
             strArray5[0] = typeof(IAsyncResult).FullName;
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:67,代码来源:SoapProtocolImporter.cs

示例3: GenerateMethod


//.........这里部分代码省略.........
                    UnsupportedOperationWarning(Res.GetString(Res.CodeGenSupportParameterAttributes, ServiceImporter.CodeGenerator.GetType().Name));
                    return null;
                }
                j++;
            }

            CodeFlags[] parameterFlags = SoapParameter.GetCodeFlags(parameters.Parameters, parameters.CheckSpecifiedCount);
            string[] parameterTypes = SoapParameter.GetTypeFullNames(parameters.Parameters, parameters.CheckSpecifiedCount, ServiceImporter.CodeGenerator);
            string returnType = parameters.Return == null ? typeof(void).FullName : WebCodeGenerator.FullTypeName(parameters.Return, ServiceImporter.CodeGenerator);

            CodeMemberMethod mainCodeMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, methodName, 
                                        parameterFlags, 
                                        parameterTypes,
                                        SoapParameter.GetNames(parameters.Parameters, parameters.CheckSpecifiedCount),
                                        paramsMetadata,
                                        returnType,
                                        metadata, 
                                        CodeFlags.IsPublic | (Style == ServiceDescriptionImportStyle.Client ? 0 : CodeFlags.IsAbstract));

            mainCodeMethod.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true));

            if (parameters.Return != null) {
                if (soapRequestBinding.Use == SoapBindingUse.Encoded)
                    soapExporter.AddMappingMetadata(mainCodeMethod.ReturnTypeCustomAttributes, parameters.Return, parameters.Return.ElementName != uniqueMethodName + "Result");
                else
                    xmlExporter.AddMappingMetadata(mainCodeMethod.ReturnTypeCustomAttributes, parameters.Return, response.Namespace, parameters.Return.ElementName != uniqueMethodName + "Result");

                if (mainCodeMethod.ReturnTypeCustomAttributes.Count != 0 && !ServiceImporter.CodeGenerator.Supports(GeneratorSupport.ReturnTypeAttributes)) {
                    UnsupportedOperationWarning(Res.GetString(Res.CodeGenSupportReturnTypeAttributes, ServiceImporter.CodeGenerator.GetType().Name));
                    return null;
                }
            }

            string resultsName = localIdentifiers.MakeUnique("results");

            if (Style == ServiceDescriptionImportStyle.Client) {
                bool oldAsync = (ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateOldAsync) != 0;
                bool newAsync = (ServiceImporter.CodeGenerationOptions & CodeGenerationOptions.GenerateNewAsync) != 0 && 
                    ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareEvents) && 
                    ServiceImporter.CodeGenerator.Supports(GeneratorSupport.DeclareDelegates);
                CodeExpression[] invokeParams = new CodeExpression[2];
                CreateInvokeParams(invokeParams, uniqueMethodName, parameters.InParameters, parameters.InCheckSpecifiedCount);
                CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "Invoke", invokeParams);
                WriteReturnMappings(mainCodeMethod, invoke, parameters, resultsName);

                if (oldAsync) {
                    int inCount = parameters.InParameters.Count + parameters.InCheckSpecifiedCount;

                    string[] asyncParameterTypes = new string[inCount + 2];
                    SoapParameter.GetTypeFullNames(parameters.InParameters, asyncParameterTypes, 0, parameters.InCheckSpecifiedCount, ServiceImporter.CodeGenerator);
                    asyncParameterTypes[inCount] = typeof(AsyncCallback).FullName;
                    asyncParameterTypes[inCount + 1] = typeof(object).FullName;

                    string[] asyncParameterNames = new string[inCount + 2];
                    SoapParameter.GetNames(parameters.InParameters, asyncParameterNames, 0, parameters.InCheckSpecifiedCount);
                    asyncParameterNames[inCount] = "callback";
                    asyncParameterNames[inCount + 1] = "asyncState";

                    CodeFlags[] asyncParameterFlags = new CodeFlags[inCount + 2];

                    CodeMemberMethod beginCodeMethod = WebCodeGenerator.AddMethod(this.CodeTypeDeclaration, "Begin" + uniqueMethodName, 
                        asyncParameterFlags,
                        asyncParameterTypes, 
                        asyncParameterNames, 
                        typeof(IAsyncResult).FullName, 
                        null, 
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:67,代码来源:SoapProtocolImporter.cs

示例4: SoapParameters

 internal SoapParameters(XmlMembersMapping request, XmlMembersMapping response, string[] parameterOrder, CodeIdentifiers identifiers)
 {
     ArrayList mappingsList = new ArrayList();
     ArrayList list2 = new ArrayList();
     AddMappings(mappingsList, request);
     if (response != null)
     {
         AddMappings(list2, response);
     }
     if (parameterOrder != null)
     {
         for (int i = 0; i < parameterOrder.Length; i++)
         {
             string elementName = parameterOrder[i];
             XmlMemberMapping requestMapping = FindMapping(mappingsList, elementName);
             SoapParameter parameter = new SoapParameter();
             if (requestMapping != null)
             {
                 if (RemoveByRefMapping(list2, requestMapping))
                 {
                     parameter.codeFlags = CodeFlags.IsByRef;
                 }
                 parameter.mapping = requestMapping;
                 mappingsList.Remove(requestMapping);
                 this.AddParameter(parameter);
             }
             else
             {
                 XmlMemberMapping mapping2 = FindMapping(list2, elementName);
                 if (mapping2 != null)
                 {
                     parameter.codeFlags = CodeFlags.IsOut;
                     parameter.mapping = mapping2;
                     list2.Remove(mapping2);
                     this.AddParameter(parameter);
                 }
             }
         }
     }
     foreach (XmlMemberMapping mapping3 in mappingsList)
     {
         SoapParameter parameter2 = new SoapParameter();
         if (RemoveByRefMapping(list2, mapping3))
         {
             parameter2.codeFlags = CodeFlags.IsByRef;
         }
         parameter2.mapping = mapping3;
         this.AddParameter(parameter2);
     }
     if (list2.Count > 0)
     {
         if (!((XmlMemberMapping) list2[0]).CheckSpecified)
         {
             this.ret = (XmlMemberMapping) list2[0];
             list2.RemoveAt(0);
         }
         foreach (XmlMemberMapping mapping4 in list2)
         {
             SoapParameter parameter3 = new SoapParameter {
                 mapping = mapping4,
                 codeFlags = CodeFlags.IsOut
             };
             this.AddParameter(parameter3);
         }
     }
     foreach (SoapParameter parameter4 in this.parameters)
     {
         parameter4.name = identifiers.MakeUnique(CodeIdentifier.MakeValid(parameter4.mapping.MemberName));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:70,代码来源:SoapParameters.cs

示例5: SoapParameters

        internal SoapParameters(XmlMembersMapping request, XmlMembersMapping response, string[] parameterOrder, CodeIdentifiers identifiers) {
            ArrayList requestList = new ArrayList();
            ArrayList responseList = new ArrayList();

            AddMappings(requestList, request);
            if (response != null) AddMappings(responseList, response);

            if (parameterOrder != null) {
                for (int i = 0; i < parameterOrder.Length; i++) {
                    string elementName = parameterOrder[i];
                    XmlMemberMapping requestMapping = FindMapping(requestList, elementName);
                    SoapParameter parameter = new SoapParameter();
                    if (requestMapping != null) {
                        if (RemoveByRefMapping(responseList, requestMapping))
                            parameter.codeFlags = CodeFlags.IsByRef;
                        parameter.mapping = requestMapping;
                        requestList.Remove(requestMapping);
                        AddParameter(parameter);
                    }
                    else {
                        XmlMemberMapping responseMapping = FindMapping(responseList, elementName);
                        if (responseMapping != null) {
                            parameter.codeFlags = CodeFlags.IsOut;
                            parameter.mapping = responseMapping;
                            responseList.Remove(responseMapping);
                            AddParameter(parameter);
                        }
                    }
                }
            }

            foreach (XmlMemberMapping requestMapping in requestList) {
                SoapParameter parameter = new SoapParameter();
                if (RemoveByRefMapping(responseList, requestMapping))
                    parameter.codeFlags = CodeFlags.IsByRef;
                parameter.mapping = requestMapping;
                AddParameter(parameter);
            }

            if (responseList.Count > 0) {
                if (!((XmlMemberMapping) responseList[0]).CheckSpecified) {
                    ret = (XmlMemberMapping)responseList[0];
                    responseList.RemoveAt(0);
                }
                foreach (XmlMemberMapping responseMapping in responseList) {
                    SoapParameter parameter = new SoapParameter();
                    parameter.mapping = responseMapping;
                    parameter.codeFlags = CodeFlags.IsOut;
                    AddParameter(parameter);
                }
            }

            foreach (SoapParameter parameter in parameters) {
                parameter.name = identifiers.MakeUnique(CodeIdentifier.MakeValid(parameter.mapping.MemberName));
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:56,代码来源:SoapProtocolImporter.cs


注:本文中的System.Xml.Serialization.CodeIdentifiers.MakeUnique方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。