using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Edge.Core.Processor.Dispatcher.Attributes { /// /// Providing the jsonSchemas for method's or ctor's parameters. /// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = false)] public class ParamsJsonSchemas : Attribute { /// /// the jsonSchemas persisted in a resource file. /// /// the resource file name, only the '.json' file extension can be omit. public ParamsJsonSchemas(string schemaEmbededResourceName) { if (schemaEmbededResourceName.ToLower().EndsWith(".json")) this.SchemaEmbededResourceName = schemaEmbededResourceName.Trim(); else this.SchemaEmbededResourceName = schemaEmbededResourceName.Trim() + ".json"; } /// /// the json schema's are defined with inline strings. /// /// one for each parameter public ParamsJsonSchemas(string[] schemaStrings) { this.SchemaStrings = schemaStrings; } ///// ///// Not specify jsonSchema, system will auto generate json schema for parameters ///// //public ParamsJsonSchemas() { } /// /// public string SchemaEmbededResourceName { get; private set; } /// /// Array of Json Schema strings, each array element is for a ctor parameter. /// public string[] SchemaStrings { get; private set; } } /// /// Declare the parts that the current host parts(marked this attribute) required. /// Mostly used in DeviceHandler that require combine with specific MessageBase, /// MessageCutter, MessageParser, Communicator, or DeviceProcessor, to construct a Processor. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] public class MetaPartsRequired : Attribute { /// /// /// other parts's type public MetaPartsRequired(Type requiredPartsType) { this.RequiredPartsType = requiredPartsType; } public Type RequiredPartsType { get; private set; } //public MetaPartsRequired(bool isSystemInternalComponent, string description) //{ // this.IsSystemInternalComponent = isSystemInternalComponent; // this.Description = description; //} ///// ///// Use this Ctor for the purpose of declaring some info for host class itself. ///// ///// the purpose the host class for, may used for generate in UI //public MetaPartsRequired(string description) : this(false, description) //{ //} //public bool IsSystemInternalComponent { get; private set; } //public string Description { get; private set; } /// /// This value will be used in instantiate the PartsRequired. /// Each element in Array is a json value for corresponding ctor parameter that will be used to instantiate parts' instance. /// like: [1, "helloWorld", "{"name":"Elsa","age":"10"}"] /// public string[] DefaultCtorParamsJsonStrings { get; set; } = new string[] { }; } /// /// Used to declare readable info for DeviceHandler or AppProcessor. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public class MetaPartsDescriptor : Attribute { /// /// The readable content for decorated class. /// /// text that support multi-language, follow the sample string-> lang-zh-cn:X加油机lang-en-us:Xdispenser /// text that support multi-language, follow the sample string-> lang-zh-cn:用于驱动加油机lang-en-us:Used for driven dispenser public MetaPartsDescriptor(string displayName, string description) { this.DisplayName = displayName; this.Description = description; } /// /// The readable content for decorated class, with category specified(by add tags). /// /// text that support multi-language, follow the sample string-> lang-zh-cn:X加油机lang-en-us:Xdispenser /// text that support multi-language, follow the sample string-> lang-zh-cn:用于驱动加油机lang-en-us:Used for driven dispenser /// the category of the target, like: Pump, Atg, Terminal and ect. Multi-language is support here, if multi-lang string value is provided, then should at least provide english version of the value, which will be used for filtering(show me api feature). public MetaPartsDescriptor(string displayName, string description, string[] tags) { this.DisplayName = displayName; this.Description = description; this.Tags = tags; } public string[] Tags { get; private set; } public string DisplayName { get; private set; } public string Description { get; private set; } /// /// Gets or sets the value to indicates the decorated class(Either DeviceHanlder or AppProcessor) /// is a build-in and has no business logic module, this kind of module is always used for /// providing special management purpose APIs. /// public bool IsSystemInternalComponent { get; set; } /// /// if no concrete parameter specified, this default value will be pass into Parts(defined by Type) to try /// to instantiate the Parts instance. /// Each element in Array is a json value for corresponding ctor parameter that will be used to instantiate parts' instance. /// like: [1, "helloWorld", "{"name":"Peppa","age":"10"}"] /// public string[] DefaultCtorParamsJsonStrings { get; set; } } }