コード例 #1
0
        public static Typ OfReflectionClass(FileDescriptor desc)
        {
            string protoFile = desc.Name;
            string name      = Path.GetFileNameWithoutExtension(protoFile);

            return(Manual(desc.CSharpNamespace(), name.ToUpperCamelCase() + "Reflection"));
        }
コード例 #2
0
            public Definition(FileDescriptor fileDesc, MessageDescriptor msgDesc, string type, string nameField, CommonResource common, IEnumerable <string> patterns)
            {
                MsgDesc  = msgDesc;
                FileName = fileDesc.Name;
                UnifiedResourceTypeName = type;
                var typeNameParts = type.Split('/');

                if (typeNameParts.Length != 2)
                {
                    throw new InvalidOperationException($"Invalid unified resource name: '{type}' used in message '{msgDesc?.Name}'");
                }
                ShortName = typeNameParts[1];
                FieldName = ShortName.ToLowerCamelCase();
                NameField = string.IsNullOrEmpty(nameField) ? "name" : nameField;
                DocName   = ShortName;
                Patterns  = patterns.Select(x => new Pattern(x)).ToList();
                if (patterns.Distinct().Count() != Patterns.Count)
                {
                    throw new InvalidOperationException("All patterns must be unique within a resource-name.");
                }
                IsCommon        = common != null;
                ResourceNameTyp = IsCommon ?
                                  Typ.Manual(common.CsharpNamespace, common.CsharpClassName) :
                                  Typ.Manual(fileDesc.CSharpNamespace(), $"{ShortName}Name");
                ResourceParserTyp = ResourceNameTyp;
                IsUnparsed        = false;
            }