Esempio n. 1
0
        protected MessageEditor(
            ProjectData projectData,
            SetupConfig config,
            MessageDescriptor descriptor,
            ProtoMessageType messageType,
            MessageInfo defaultMessage,
            FileInfo protoFile,
            EnumInfoHelper enumInfoHelper)
        {
            this.m_ProjectData      = projectData;
            this.m_Config           = config;
            this.m_DefaultMessage   = defaultMessage;
            this.m_MessageType      = messageType;
            this.m_Descriptor       = descriptor;
            this.m_EnumInfoHelper   = enumInfoHelper;
            this.m_SavedEditorState =
                new EditorState(m_Config.GetUseAdvanced(m_MessageType), new MessageInfo(m_Descriptor));
            // If using advanced mode, use the saved editor state which has user-inserted fields to prevent
            // inconsistencies.
            EditorState defaultEditorState = m_Config.GetUseAdvanced(m_MessageType)
                ? m_SavedEditorState
                : new EditorState(m_Config.GetUseAdvanced(m_MessageType), defaultMessage);

            this.m_EditorStatePrefs = new EditorStatePrefs <EditorState>(messageType.ToString(), defaultEditorState);
            this.m_EditorState      = m_EditorStatePrefs.Get();
            this.m_ProtoFile        = protoFile;
            CheckValidationErrors();
        }
Esempio n. 2
0
        public bool GetUseAdvanced(ProtoMessageType type)
        {
            switch (type)
            {
            case ProtoMessageType.Annotation: return(useAdvancedAnnotations);

            case ProtoMessageType.FidelityParams: return(useAdvancedFidelityParameters);

            default: throw new System.ArgumentException("Unknown message type");
            }
        }
Esempio n. 3
0
        public void SetUseAdvanced(bool useAdvanced, ProtoMessageType type)
        {
            switch (type)
            {
            case ProtoMessageType.Annotation:
                useAdvancedAnnotations = useAdvanced;
                break;

            case ProtoMessageType.FidelityParams:
                useAdvancedFidelityParameters = useAdvanced;
                break;

            default: throw new System.ArgumentException("Unknown message type");
            }
        }
Esempio n. 4
0
        /// <summary>
        ///     Construct a FieldInfo with the default values for a field.
        ///     FidelityParameters message's field has default Int32 type.
        ///     Annotation message's field has default Enum type.
        /// </summary>
        public FieldInfo(FileDescriptor fileDescriptor, ProtoMessageType type, int index)
        {
            name          = k_DefaultFieldName + index;
            enumTypeIndex = 0;

            // Only enums are allowed for annotations.
            if (type == ProtoMessageType.Annotation)
            {
                fieldType = FieldType.Enum;
                enumType  = fileDescriptor.EnumTypes[enumTypeIndex].Name;
            }
            else
            {
                fieldType = FieldType.Int32;
                enumType  = null;
            }
        }
 protected MessageEditor(
     SetupConfig config,
     MessageDescriptor descriptor,
     ProtoMessageType messageType,
     MessageInfo defaultMessage,
     FileInfo protoFile,
     EnumInfoHelper enumInfoHelper)
 {
     this.m_Config           = config;
     this.m_DefaultMessage   = defaultMessage;
     this.m_MessageType      = messageType;
     this.m_Descriptor       = descriptor;
     this.m_EnumInfoHelper   = enumInfoHelper;
     this.m_EditorStatePrefs = new EditorStatePrefs <EditorState>(messageType.ToString(),
                                                                  new EditorState(m_Config.GetUseAdvanced(m_MessageType), defaultMessage));
     this.m_EditorState      = m_EditorStatePrefs.Get();
     this.m_ProtoFile        = protoFile;
     this.m_SavedEditorState =
         new EditorState(m_Config.GetUseAdvanced(m_MessageType), new MessageInfo(m_Descriptor));
     CheckValidationErrors();
 }