示例#1
0
        public InterfaceDataRecord CreateInterfaceRepresentation(ModelInterface intfc)
        {
            if (intfc == null)
            {
                return(null);
            }
            InterfaceDataRecord raw = new InterfaceDataRecord(intfc.PersistentId);

            if (intfc is ModelInterface)
            {
                // Common parameters
                AddCommonInterfacePropertiesAsNVPairs(intfc, raw);
                raw.AddProperty(AgentKeys.AgentName, AgentId);    // mark it as mine
                raw.AddProperty(AgentKeys.VisaIntfType, VisaIntfTypeString);
            }

            // Unique parameters
            var specificIntfc = intfc as ModelInterfaceSample;

            if (specificIntfc != null)
            {
                AddInfoToInterface(raw, specificIntfc);
            }
            return(raw);
        }
示例#2
0
        private ModelElement ConstructInterface(string persistentID, Dictionary <string, string> rawProperties)
        {
            var intfcRecord = new InterfaceDataRecord(persistentID);

            intfcRecord.Properties = rawProperties;
            var element = ReconstituteInterface(intfcRecord);

            return(element);
        }
示例#3
0
        public bool CanReconstituteThis(InterfaceDataRecord raw)
        {
            string recordType = raw.GetString(AgentKeys.RecordType);
            string agent      = raw.GetString(AgentKeys.AgentName);

            if (agent == string.Empty)
            {
                agent = AgentId;
            }
            bool canHandle = false;

            if (agent == AgentId && recordType == MODELINTERFACE_RECORDTYPE)
            {
                canHandle = true;
            }
            return(canHandle);
        }
示例#4
0
        public ModelInterface ReconstituteInterface(InterfaceDataRecord raw)
        {
            if (raw == null)
            {
                return(null);
            }
            if (!CanReconstituteThis(raw))
            {
                return(null);
            }

            var intfc = new ModelInterfaceSample();

            ExtractCommonInterfacePropertiesFromNVPairs(raw, intfc);
            intfc.ConnectionTimeout = raw.GetInt(Consts.CONNECTION_TIMEOUT_KEY);
            intfc.BusAddress        = raw.GetInt(Consts.BUS_ADDRESS_KEY);
            intfc.Dirty             = false;

            return(intfc);
        }
示例#5
0
 private static void AddInfoToInterface(InterfaceDataRecord raw, ModelInterfaceSample specificIntfc)
 {
     raw.AddProperty(Consts.CONNECTION_TIMEOUT_KEY, specificIntfc.ConnectionTimeout.ToString());
     raw.AddProperty(Consts.BUS_ADDRESS_KEY, specificIntfc.BusAddress.ToString());
 }
 private ModelElement ConstructInterface(string persistentID, Dictionary<string, string> rawProperties)
 {
     var intfcRecord = new InterfaceDataRecord(persistentID);
     intfcRecord.Properties = rawProperties;
     var element = ReconstituteInterface(intfcRecord);
     return element;
 }
 private static void AddInfoToInterface(InterfaceDataRecord raw, ModelInterfaceSample specificIntfc)
 {
     raw.AddProperty(Consts.CONNECTION_TIMEOUT_KEY, specificIntfc.ConnectionTimeout.ToString());
     raw.AddProperty(Consts.BUS_ADDRESS_KEY, specificIntfc.BusAddress.ToString());
 }
        public ModelInterface ReconstituteInterface(InterfaceDataRecord raw)
        {
            if (raw == null) return null;
            if (!CanReconstituteThis(raw)) return null;

            var intfc = new ModelInterfaceSample();
            ExtractCommonInterfacePropertiesFromNVPairs(raw, intfc);
            intfc.ConnectionTimeout = raw.GetInt(Consts.CONNECTION_TIMEOUT_KEY);
            intfc.BusAddress = raw.GetInt(Consts.BUS_ADDRESS_KEY);
            intfc.Dirty = false;

            return intfc;
        }
        public InterfaceDataRecord CreateInterfaceRepresentation(ModelInterface intfc)
        {
            if (intfc == null) return null;
            InterfaceDataRecord raw = new InterfaceDataRecord(intfc.PersistentId);

            if (intfc is ModelInterface)
            {
                // Common parameters
                AddCommonInterfacePropertiesAsNVPairs(intfc, raw);
                raw.AddProperty(AgentKeys.AgentName, AgentId);    // mark it as mine
                raw.AddProperty(AgentKeys.VisaIntfType, VisaIntfTypeString);
            }

            // Unique parameters
            var specificIntfc = intfc as ModelInterfaceSample;
            if (specificIntfc != null)
            {
                AddInfoToInterface(raw, specificIntfc);
            }
            return raw;
        }
示例#10
0
 public bool CanReconstituteThis(InterfaceDataRecord raw)
 {
     string recordType = raw.GetString(AgentKeys.RecordType);
     string agent = raw.GetString(AgentKeys.AgentName);
     if (agent == string.Empty) agent = AgentId;
     bool canHandle = false;
     if (agent == AgentId && recordType == MODELINTERFACE_RECORDTYPE)
     {
         canHandle = true;
     }
     return canHandle;
 }