예제 #1
0
 public MimeTextMatch()
 {
     capture    = 0;
     group      = 1;
     ignoreCase = false;
     matches    = null;
     name       = String.Empty;
     pattern    = String.Empty;
     repeats    = 1;
     type       = String.Empty;
 }
		public MimeTextMatch ()
		{
			capture = 0;
			group = 1;
			ignoreCase = false;
			matches = null;
			name = String.Empty;
			pattern = String.Empty;
			repeats = 1;
			type = String.Empty;
		}
예제 #3
0
 internal void SetParent(MimeTextMatchCollection matches)
 {
     this.matches = matches;
 }
예제 #4
0
        void GenerateCode(string typeName, MimeTextMatchCollection matches, CodeGenerationOptions options)
        {
            CodeIdentifiers     members   = new CodeIdentifiers();
            CodeTypeDeclaration codeClass = WebCodeGenerator.AddClass(ImportContext.CodeNamespace, typeName, string.Empty, new string[0], null, CodeFlags.IsPublic,
                                                                      ImportContext.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes));

            string[] fieldTypeNames = new string[matches.Count];
            for (int i = 0; i < matches.Count; i++)
            {
                MimeTextMatch match = matches[i];
                string        name  = members.AddUnique(CodeIdentifier.MakeValid(match.Name.Length == 0 ? methodName + "Match" : match.Name), match);
                CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection();
                if (match.Pattern.Length == 0)
                {
                    throw new ArgumentException(Res.GetString(Res.WebTextMatchMissingPattern));
                }

                CodeExpression pattern       = new CodePrimitiveExpression(match.Pattern);
                int            numPropValues = 0;
                if (match.Group != 1)
                {
                    numPropValues++;
                }
                if (match.Capture != 0)
                {
                    numPropValues++;
                }
                if (match.IgnoreCase)
                {
                    numPropValues++;
                }
                if (match.Repeats != 1 && match.Repeats != int.MaxValue)
                {
                    numPropValues++;
                }
                CodeExpression[] propertyValues = new CodeExpression[numPropValues];
                string[]         propertyNames  = new string[propertyValues.Length];
                numPropValues = 0;
                if (match.Group != 1)
                {
                    propertyValues[numPropValues] = new CodePrimitiveExpression(match.Group);
                    propertyNames[numPropValues]  = "Group";
                    numPropValues++;
                }
                if (match.Capture != 0)
                {
                    propertyValues[numPropValues] = new CodePrimitiveExpression(match.Capture);
                    propertyNames[numPropValues]  = "Capture";
                    numPropValues++;
                }
                if (match.IgnoreCase)
                {
                    propertyValues[numPropValues] = new CodePrimitiveExpression(match.IgnoreCase);
                    propertyNames[numPropValues]  = "IgnoreCase";
                    numPropValues++;
                }
                if (match.Repeats != 1 && match.Repeats != int.MaxValue)
                {
                    propertyValues[numPropValues] = new CodePrimitiveExpression(match.Repeats);
                    propertyNames[numPropValues]  = "MaxRepeats";
                    numPropValues++;
                }
                WebCodeGenerator.AddCustomAttribute(metadata, typeof(MatchAttribute), new CodeExpression[] { pattern }, propertyNames, propertyValues);

                string fieldTypeName;
                if (match.Matches.Count > 0)
                {
                    fieldTypeName     = ImportContext.ClassNames.AddUnique(CodeIdentifier.MakeValid(match.Type.Length == 0 ? name : match.Type), match);
                    fieldTypeNames[i] = fieldTypeName;
                }
                else
                {
                    fieldTypeName = typeof(string).FullName;
                }
                if (match.Repeats != 1)
                {
                    fieldTypeName += "[]";
                }

                CodeTypeMember member = WebCodeGenerator.AddMember(codeClass, fieldTypeName, name, null, metadata, CodeFlags.IsPublic, options);

                if (match.Matches.Count == 0 && match.Type.Length > 0)
                {
                    ImportContext.Warnings |= ServiceDescriptionImportWarnings.OptionalExtensionsIgnored;
                    ProtocolImporter.AddWarningComment(member.Comments, Res.GetString(Res.WebTextMatchIgnoredTypeWarning));
                }
            }

            for (int i = 0; i < fieldTypeNames.Length; i++)
            {
                string fieldTypeName = fieldTypeNames[i];
                if (fieldTypeName != null)
                {
                    GenerateCode(fieldTypeName, matches[i].Matches, options);
                }
            }
        }
 public MimeTextBinding()
 {
     matches = new MimeTextMatchCollection();
 }
		internal void SetParent (MimeTextMatchCollection matches) 
		{
			this.matches = matches;
		}
예제 #7
0
        private void GenerateCode(string typeName, MimeTextMatchCollection matches, CodeGenerationOptions options)
        {
            CodeIdentifiers     identifiers = new CodeIdentifiers();
            CodeTypeDeclaration codeClass   = WebCodeGenerator.AddClass(base.ImportContext.CodeNamespace, typeName, string.Empty, new string[0], null, CodeFlags.IsPublic, base.ImportContext.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes));

            string[] strArray = new string[matches.Count];
            for (int i = 0; i < matches.Count; i++)
            {
                string        fullName;
                MimeTextMatch match      = matches[i];
                string        memberName = identifiers.AddUnique(CodeIdentifier.MakeValid((match.Name.Length == 0) ? (this.methodName + "Match") : match.Name), match);
                CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection();
                if (match.Pattern.Length == 0)
                {
                    throw new ArgumentException(Res.GetString("WebTextMatchMissingPattern"));
                }
                CodeExpression expression = new CodePrimitiveExpression(match.Pattern);
                int            index      = 0;
                if (match.Group != 1)
                {
                    index++;
                }
                if (match.Capture != 0)
                {
                    index++;
                }
                if (match.IgnoreCase)
                {
                    index++;
                }
                if ((match.Repeats != 1) && (match.Repeats != 0x7fffffff))
                {
                    index++;
                }
                CodeExpression[] propValues = new CodeExpression[index];
                string[]         propNames  = new string[propValues.Length];
                index = 0;
                if (match.Group != 1)
                {
                    propValues[index] = new CodePrimitiveExpression(match.Group);
                    propNames[index]  = "Group";
                    index++;
                }
                if (match.Capture != 0)
                {
                    propValues[index] = new CodePrimitiveExpression(match.Capture);
                    propNames[index]  = "Capture";
                    index++;
                }
                if (match.IgnoreCase)
                {
                    propValues[index] = new CodePrimitiveExpression(match.IgnoreCase);
                    propNames[index]  = "IgnoreCase";
                    index++;
                }
                if ((match.Repeats != 1) && (match.Repeats != 0x7fffffff))
                {
                    propValues[index] = new CodePrimitiveExpression(match.Repeats);
                    propNames[index]  = "MaxRepeats";
                    index++;
                }
                WebCodeGenerator.AddCustomAttribute(metadata, typeof(MatchAttribute), new CodeExpression[] { expression }, propNames, propValues);
                if (match.Matches.Count > 0)
                {
                    fullName    = base.ImportContext.ClassNames.AddUnique(CodeIdentifier.MakeValid((match.Type.Length == 0) ? memberName : match.Type), match);
                    strArray[i] = fullName;
                }
                else
                {
                    fullName = typeof(string).FullName;
                }
                if (match.Repeats != 1)
                {
                    fullName = fullName + "[]";
                }
                CodeTypeMember member = WebCodeGenerator.AddMember(codeClass, fullName, memberName, null, metadata, CodeFlags.IsPublic, options);
                if ((match.Matches.Count == 0) && (match.Type.Length > 0))
                {
                    HttpProtocolImporter importContext = base.ImportContext;
                    importContext.Warnings |= ServiceDescriptionImportWarnings.OptionalExtensionsIgnored;
                    ProtocolImporter.AddWarningComment(member.Comments, Res.GetString("WebTextMatchIgnoredTypeWarning"));
                }
            }
            for (int j = 0; j < strArray.Length; j++)
            {
                string str3 = strArray[j];
                if (str3 != null)
                {
                    this.GenerateCode(str3, matches[j].Matches, options);
                }
            }
        }
 private void GenerateCode(string typeName, MimeTextMatchCollection matches, CodeGenerationOptions options)
 {
     CodeIdentifiers identifiers = new CodeIdentifiers();
     CodeTypeDeclaration codeClass = WebCodeGenerator.AddClass(base.ImportContext.CodeNamespace, typeName, string.Empty, new string[0], null, CodeFlags.IsPublic, base.ImportContext.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes));
     string[] strArray = new string[matches.Count];
     for (int i = 0; i < matches.Count; i++)
     {
         string fullName;
         MimeTextMatch match = matches[i];
         string memberName = identifiers.AddUnique(CodeIdentifier.MakeValid((match.Name.Length == 0) ? (this.methodName + "Match") : match.Name), match);
         CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection();
         if (match.Pattern.Length == 0)
         {
             throw new ArgumentException(Res.GetString("WebTextMatchMissingPattern"));
         }
         CodeExpression expression = new CodePrimitiveExpression(match.Pattern);
         int index = 0;
         if (match.Group != 1)
         {
             index++;
         }
         if (match.Capture != 0)
         {
             index++;
         }
         if (match.IgnoreCase)
         {
             index++;
         }
         if ((match.Repeats != 1) && (match.Repeats != 0x7fffffff))
         {
             index++;
         }
         CodeExpression[] propValues = new CodeExpression[index];
         string[] propNames = new string[propValues.Length];
         index = 0;
         if (match.Group != 1)
         {
             propValues[index] = new CodePrimitiveExpression(match.Group);
             propNames[index] = "Group";
             index++;
         }
         if (match.Capture != 0)
         {
             propValues[index] = new CodePrimitiveExpression(match.Capture);
             propNames[index] = "Capture";
             index++;
         }
         if (match.IgnoreCase)
         {
             propValues[index] = new CodePrimitiveExpression(match.IgnoreCase);
             propNames[index] = "IgnoreCase";
             index++;
         }
         if ((match.Repeats != 1) && (match.Repeats != 0x7fffffff))
         {
             propValues[index] = new CodePrimitiveExpression(match.Repeats);
             propNames[index] = "MaxRepeats";
             index++;
         }
         WebCodeGenerator.AddCustomAttribute(metadata, typeof(MatchAttribute), new CodeExpression[] { expression }, propNames, propValues);
         if (match.Matches.Count > 0)
         {
             fullName = base.ImportContext.ClassNames.AddUnique(CodeIdentifier.MakeValid((match.Type.Length == 0) ? memberName : match.Type), match);
             strArray[i] = fullName;
         }
         else
         {
             fullName = typeof(string).FullName;
         }
         if (match.Repeats != 1)
         {
             fullName = fullName + "[]";
         }
         CodeTypeMember member = WebCodeGenerator.AddMember(codeClass, fullName, memberName, null, metadata, CodeFlags.IsPublic, options);
         if ((match.Matches.Count == 0) && (match.Type.Length > 0))
         {
             HttpProtocolImporter importContext = base.ImportContext;
             importContext.Warnings |= ServiceDescriptionImportWarnings.OptionalExtensionsIgnored;
             ProtocolImporter.AddWarningComment(member.Comments, Res.GetString("WebTextMatchIgnoredTypeWarning"));
         }
     }
     for (int j = 0; j < strArray.Length; j++)
     {
         string str3 = strArray[j];
         if (str3 != null)
         {
             this.GenerateCode(str3, matches[j].Matches, options);
         }
     }
 }
예제 #9
0
		public MimeTextBinding ()
		{
			matches = new MimeTextMatchCollection ();
		}
        void GenerateCode(string typeName, MimeTextMatchCollection matches, CodeGenerationOptions options) {
            CodeIdentifiers members = new CodeIdentifiers();
            CodeTypeDeclaration codeClass = WebCodeGenerator.AddClass(ImportContext.CodeNamespace, typeName, string.Empty, new string[0], null, CodeFlags.IsPublic, 
                ImportContext.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes));

            string[] fieldTypeNames = new string[matches.Count];
            for (int i = 0; i < matches.Count; i++) {
                MimeTextMatch match = matches[i];
                string name = members.AddUnique(CodeIdentifier.MakeValid(match.Name.Length == 0 ? methodName + "Match" : match.Name), match);
                CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection();
                if (match.Pattern.Length == 0) throw new ArgumentException(Res.GetString(Res.WebTextMatchMissingPattern));

                CodeExpression pattern = new CodePrimitiveExpression(match.Pattern);
                int numPropValues = 0;
                if (match.Group != 1) 
                    numPropValues++;
                if (match.Capture != 0)
                    numPropValues++;
                if (match.IgnoreCase)
                    numPropValues++;
                if (match.Repeats != 1 && match.Repeats != int.MaxValue)
                    numPropValues++;
                CodeExpression[] propertyValues = new CodeExpression[numPropValues];
                string[] propertyNames = new string[propertyValues.Length];
                numPropValues = 0;
                if (match.Group != 1) {
                    propertyValues[numPropValues] = new CodePrimitiveExpression(match.Group);
                    propertyNames[numPropValues] = "Group";
                    numPropValues++;
                }
                if (match.Capture != 0) {
                    propertyValues[numPropValues] = new CodePrimitiveExpression(match.Capture);
                    propertyNames[numPropValues] = "Capture";
                    numPropValues++;
                }
                if (match.IgnoreCase) {
                    propertyValues[numPropValues] = new CodePrimitiveExpression(match.IgnoreCase);
                    propertyNames[numPropValues] = "IgnoreCase";
                    numPropValues++;
                }
                if (match.Repeats != 1 && match.Repeats != int.MaxValue) {
                    propertyValues[numPropValues] = new CodePrimitiveExpression(match.Repeats);
                    propertyNames[numPropValues] = "MaxRepeats";
                    numPropValues++;
                }
                WebCodeGenerator.AddCustomAttribute(metadata, typeof(MatchAttribute), new CodeExpression[] { pattern }, propertyNames, propertyValues);

                string fieldTypeName;
                if (match.Matches.Count > 0) {
                    fieldTypeName = ImportContext.ClassNames.AddUnique(CodeIdentifier.MakeValid(match.Type.Length == 0 ? name : match.Type), match);
                    fieldTypeNames[i] = fieldTypeName;
                }
                else {
                    fieldTypeName = typeof(string).FullName;
                }
                if (match.Repeats != 1)
                    fieldTypeName += "[]";
                
                CodeTypeMember member = WebCodeGenerator.AddMember(codeClass, fieldTypeName, name, null, metadata, CodeFlags.IsPublic, options);
                
                if (match.Matches.Count == 0 && match.Type.Length > 0) {
                    ImportContext.Warnings |= ServiceDescriptionImportWarnings.OptionalExtensionsIgnored;
                    ProtocolImporter.AddWarningComment(member.Comments, Res.GetString(Res.WebTextMatchIgnoredTypeWarning));
                }
            }

            for (int i = 0; i < fieldTypeNames.Length; i++) {
                string fieldTypeName = fieldTypeNames[i];
                if (fieldTypeName != null) {
                    GenerateCode(fieldTypeName, matches[i].Matches, options);
                }
            }
        }