Esempio n. 1
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public ComponentDeclaration(ComponentIDEnumeration id, string displayName, int numberOfTerminals, ComponentType componentType)
 {
     ID                = id;
     DisplayName       = displayName;
     NumberOfTerminals = numberOfTerminals;
     ComponentType     = componentType;
 }
Esempio n. 2
0
        /// <summary>
        /// Constructs a new <see cref="IBaseComponent"/> based on the given component id
        /// </summary>
        /// <param name="componentID"></param>
        /// <returns></returns>
        public IBaseComponent Construct(ComponentIDEnumeration componentID)
        {
            if (_AssociatedInterfaces.TryGetValue(componentID, out var associatedInterface) &&
                _AssociatedTypes.TryGetValue(associatedInterface, out var result))
            {
                return(Activator.CreateInstance(result) as IBaseComponent);
            }

            throw new ArgumentException($"No component matches the ID: {componentID}");
        }
Esempio n. 3
0
 /// <summary>
 /// Method used as a helper when performing quick actions based on placing parts
 /// </summary>
 /// <param name="componentID"></param>
 private void PlacePartHelper(ComponentIDEnumeration componentID) => AppViewModel.Singleton.DesignVM.ComponentToAdd =
     IoC.Resolve <IComponentFactory>().GetDeclaration(componentID);
Esempio n. 4
0
 /// <summary>
 /// Returns declaration of a component based on its ID
 /// </summary>
 /// <param name="componentID"></param>
 /// <returns></returns>
 public IComponentDeclaration GetDeclaration(ComponentIDEnumeration componentID) =>
 _ImplementedComponents.Find((component) => component.ID == componentID);