Example #1
0
 private ProviderHandler(
     Type type,
     ProviderDescriptionAttribute pluginDescriptionAttribute,
     ProviderCapabilityAttribute capabilityAttributes)
 {
     Initialize(type, pluginDescriptionAttribute, capabilityAttributes);
 }
Example #2
0
 internal ProviderHandler(ProviderHandler fromCopy)
 {
     m_type = fromCopy.m_type;
     m_descriptionAttribute = fromCopy.m_descriptionAttribute;
     m_capabilityAttribute  = fromCopy.m_capabilityAttribute;
     m_provider             = (IProvider)Activator.CreateInstance(m_type);
     m_internalId           = fromCopy.InternalId;
     VersionChanged         = fromCopy.VersionChanged;
 }
Example #3
0
 private void Initialize(
     Type type,
     ProviderDescriptionAttribute pluginDescriptionAttribute,
     ProviderCapabilityAttribute capabilityAttributes)
 {
     this.m_type            = type;
     m_descriptionAttribute = pluginDescriptionAttribute;
     m_capabilityAttribute  = capabilityAttributes;
     m_provider             = (IProvider)Activator.CreateInstance(type);
 }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="providerAttributes"></param>
        /// <returns>True if a new provider is saved; False if an existing one is found</returns>
        internal static bool TrySaveProvider(ProviderDescriptionAttribute providerAttributes, out int internalId)
        {
            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                var providerQuery =
                    from p in context.RTProviderSet
                    where p.ReferenceName.Equals(providerAttributes.Id) &&
                    p.FriendlyName.Equals(providerAttributes.Name) &&
                    (p.ProviderVersion.Equals(providerAttributes.Version) || string.IsNullOrEmpty(p.ProviderVersion))
                    select p;

                if (providerQuery.Count() > 0)
                {
                    RTProvider existingProvider = providerQuery.First();
                    internalId = existingProvider.Id;

                    if (string.IsNullOrEmpty(existingProvider.ProviderVersion))
                    {
                        // this is possible in older version of the toolkit
                        // we need to fill up the missing info and assume that the provider was not in DB
                        existingProvider.ProviderVersion = providerAttributes.Version;
                        context.TrySaveChanges();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                RTProvider rtProvider = RTProvider.CreateRTProvider(0, providerAttributes.Id, providerAttributes.Name);
                rtProvider.ProviderVersion = providerAttributes.Version;

                context.AddToRTProviderSet(rtProvider);
                context.TrySaveChanges();

                internalId = rtProvider.Id;
                return(true);
            }
        }