Ejemplo n.º 1
0
 public virtual void CopyFrom(System.Collections.IDictionary dict, bool deep)
 {
     if ((dict == null))
     {
         throw new System.ArgumentNullException("dict");
     }
     if ((dict.Contains("Id") == true))
     {
         this.Id = ((System.Guid)(ConvertUtilities.ChangeType(dict["Id"], typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     }
     if ((dict.Contains("ValueType") == true))
     {
         this.ValueType = ((string)(ConvertUtilities.ChangeType(dict["ValueType"], typeof(string), default(string))));
     }
     if ((dict.Contains("Value") == true))
     {
         this.Value = ((string)(ConvertUtilities.ChangeType(dict["Value"], typeof(string), default(string))));
     }
     if ((dict.Contains("Type") == true))
     {
         this.Type = ((string)(ConvertUtilities.ChangeType(dict["Type"], typeof(string), default(string))));
     }
     if ((dict.Contains("RoleId") == true))
     {
         this.RoleId = ((System.Guid)(ConvertUtilities.ChangeType(dict["RoleId"], typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.CopyFrom, false, dict));
 }
Ejemplo n.º 2
0
        public static object GetValue(this IDictionary <string, object> dictionary, string key, Type type, object defaultValue)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            object def = ConvertUtilities.ChangeType(defaultValue, type, CultureInfo.CurrentCulture);

            if (dictionary == null)
            {
                return(def);
            }

            object o;

            if (!dictionary.TryGetValue(key, out o))
            {
                return(def);
            }
            if (type == typeof(DateTime) && o != null)
            {
                return(JsonUtilities.TryParseDateTime(o.ToString()));
            }
            return(ConvertUtilities.ChangeType(o, type, def, CultureInfo.CurrentCulture));
        }
Ejemplo n.º 3
0
 public virtual void CopyFrom(System.Collections.IDictionary dict, bool deep)
 {
     if ((dict == null))
     {
         throw new System.ArgumentNullException("dict");
     }
     if ((dict.Contains("Id") == true))
     {
         this.Id = ((System.Guid)(ConvertUtilities.ChangeType(dict["Id"], typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     }
     if ((dict.Contains("Name") == true))
     {
         this.Name = ((string)(ConvertUtilities.ChangeType(dict["Name"], typeof(string), default(string))));
     }
     if ((dict.Contains("Quantity") == true))
     {
         this.Quantity = ((int)(ConvertUtilities.ChangeType(dict["Quantity"], typeof(int), CodeFluentPersistence.DefaultInt32Value)));
     }
     if ((dict.Contains("Label") == true))
     {
         this.Label = ((string)(ConvertUtilities.ChangeType(dict["Label"], typeof(string), default(string))));
     }
     if ((dict.Contains("ListId") == true))
     {
         this.ListId = ((System.Guid)(ConvertUtilities.ChangeType(dict["ListId"], typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.CopyFrom, false, dict));
 }
Ejemplo n.º 4
0
 public virtual void CopyFrom(System.Collections.IDictionary dict, bool deep)
 {
     if ((dict == null))
     {
         throw new System.ArgumentNullException("dict");
     }
     if ((dict.Contains("Id") == true))
     {
         this.Id = ((int)(ConvertUtilities.ChangeType(dict["Id"], typeof(int), -1)));
     }
     if ((dict.Contains("Email") == true))
     {
         this.Email = ((string)(ConvertUtilities.ChangeType(dict["Email"], typeof(string), default(string))));
     }
     if ((dict.Contains("LastName") == true))
     {
         this.LastName = ((string)(ConvertUtilities.ChangeType(dict["LastName"], typeof(string), default(string))));
     }
     if ((dict.Contains("FirstName") == true))
     {
         this.FirstName = ((string)(ConvertUtilities.ChangeType(dict["FirstName"], typeof(string), default(string))));
     }
     if ((dict.Contains("Photo") == true))
     {
         this.Photo.SavePostedFile(dict["Photo"]);
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.CopyFrom, false, dict));
 }
Ejemplo n.º 5
0
 public virtual void CopyFrom(System.Collections.IDictionary dict, bool deep)
 {
     if ((dict == null))
     {
         throw new System.ArgumentNullException("dict");
     }
     if ((dict.Contains("Id") == true))
     {
         this.Id = ((int)(ConvertUtilities.ChangeType(dict["Id"], typeof(int), -1)));
     }
     if ((dict.Contains("Quantity") == true))
     {
         this.Quantity = ((int)(ConvertUtilities.ChangeType(dict["Quantity"], typeof(int), CodeFluentPersistence.DefaultInt32Value)));
     }
     if ((dict.Contains("AvailableQuantity") == true))
     {
         this.AvailableQuantity = ((int)(ConvertUtilities.ChangeType(dict["AvailableQuantity"], typeof(int), CodeFluentPersistence.DefaultInt32Value)));
     }
     if ((dict.Contains("SpaceId") == true))
     {
         this.SpaceId = ((int)(ConvertUtilities.ChangeType(dict["SpaceId"], typeof(int), -1)));
     }
     if ((dict.Contains("PublicationId") == true))
     {
         this.PublicationId = ((int)(ConvertUtilities.ChangeType(dict["PublicationId"], typeof(int), -1)));
     }
     this.OnEntityAction(new CodeFluent.Runtime.CodeFluentEntityActionEventArgs(this, CodeFluent.Runtime.CodeFluentEntityAction.CopyFrom, false, dict));
 }
        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext sc, SettingsPropertyCollection properties)
        {
            SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();

            if (properties.Count == 0)
            {
                return(values);
            }

            string username = (string)sc["UserName"];

            if (string.IsNullOrEmpty(username))
            {
                return(values);
            }

            global::SoftFluent.Samples.GED.Security.User user = global::SoftFluent.Samples.GED.Security.User.LoadByUserName(username);

            foreach (SettingsProperty property in properties)
            {
                SettingsPropertyValue value = new SettingsPropertyValue(property);
                if (user != null)
                {
                    value.PropertyValue = ConvertUtilities.ChangeType(user.Properties[property.Name], property.PropertyType, property.DefaultValue);
                    value.Deserialized  = true;
                    value.IsDirty       = false;
                }
                values.Add(value);
            }
            return(values);
        }
        public virtual void ProcessRequest(HttpContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var state = ReadStateQueryParameter(context);

            if (!(GetValue(context, state, AuthServiceProvider.ProviderParameter) is string providerName))
            {
                return;
            }

            AuthenticationElement authenticationElement = GetAuthenticationElement();
            AuthServiceProvider   provider = GetServiceProvider(providerName);

            if (provider == null)
            {
                return;
            }

            AuthLoginOptions loginOptions = ConvertUtilities.ChangeType(GetValue(context, state, AuthServiceProvider.OptionsParameter), AuthLoginOptions.None);

            int      attempt  = 0;
            UserData userData = null;

            while (attempt < authenticationElement.MaximumRetryCount)
            {
                try
                {
                    userData = provider.GetUserData(context);
                    break;
                }
                catch (Exception ex)
                {
                    if (!OnGetUserDataError(context, ex, attempt))
                    {
                        break;
                    }

                    attempt++;
                    if (authenticationElement.RetryInterval > 0)
                    {
                        Thread.Sleep(authenticationElement.RetryInterval);
                    }
                }
            }

            if (userData == null)
            {
                Authenticate(context, provider, loginOptions);
            }
            else
            {
                Authenticate(context, provider, loginOptions, userData);
            }
        }
        public static T GetAttribute <T>(this IElement element, string name, T defaultValue)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            return(ConvertUtilities.ChangeType(element.GetAttribute(name), defaultValue));
        }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintHelp();
                return;
            }

            var commandLineParser = new CommandLineParser();

            commandLineParser.Parse(args);
            if (commandLineParser.HelpRequested)
            {
                PrintHelp();
                return;
            }

            var path        = commandLineParser.GetArgument(0);
            var extractOnly = ConvertUtilities.ChangeType(commandLineParser.GetArgument("extractOnly"), false);
            var fileLayout  = ConvertUtilities.ChangeType(commandLineParser.GetArgument("fileLayout"), FileLayout.SubDirectory);

            if (string.IsNullOrEmpty(path))
            {
                PrintHelp();
                return;
            }

            Project project = new Project();

            if (File.Exists(path))
            {
                project.Load(path);
            }

            project.OpenDirectory(new DirectoryInfo(Path.GetDirectoryName(path)));

            project.Save(path);

            if (!extractOnly)
            {
                var cultures = project.Files
                               .SelectMany(file => file.Fields)
                               .SelectMany(field => field.Values.Values)
                               .SelectMany(tuple => tuple.Keys)
                               .Where(cultureName => !string.IsNullOrEmpty(cultureName))
                               .Distinct()
                               .Select(cultureName => new CultureInfo(cultureName))
                               .ToList();

                foreach (var cultureInfo in cultures)
                {
                    project.Localize(cultureInfo, fileLayout);
                }
            }
        }
Ejemplo n.º 10
0
 public static ModelCodeFluent.Identity.RoleClaim LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     ModelCodeFluent.Identity.RoleClaim roleClaim;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     roleClaim = ModelCodeFluent.Identity.RoleClaim.Load(var);
     return(roleClaim);
 }
Ejemplo n.º 11
0
    /// <summary>
    /// Gets a script engine property.
    /// </summary>
    /// <typeparam name="T">The expected property type.</typeparam>
    /// <param name="index">The property index.</param>
    /// <param name="defaultValue">The default value if not found.</param>
    /// <returns>The value of the property or the default value.</returns>
    public T GetProperty <T>(int index, T defaultValue)
    {
        object value;

        if (!TryGetProperty(index, out value))
        {
            return(defaultValue);
        }

        return(ConvertUtilities.ChangeType(value, defaultValue));
    }
Ejemplo n.º 12
0
 public static SoftFluent.Samples.Thinktecture.IdentityServer.Role LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     SoftFluent.Samples.Thinktecture.IdentityServer.Role role;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     role = SoftFluent.Samples.Thinktecture.IdentityServer.Role.Load(var);
     return(role);
 }
Ejemplo n.º 13
0
 public static ModelCodeFluent.Vehicle LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     ModelCodeFluent.Vehicle vehicle;
     System.Guid             var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     vehicle = ModelCodeFluent.Vehicle.Load(var);
     return(vehicle);
 }
Ejemplo n.º 14
0
 public static SoftFluent.Samples.ComponentOne.User LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     SoftFluent.Samples.ComponentOne.User user;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     user = SoftFluent.Samples.ComponentOne.User.Load(var);
     return(user);
 }
Ejemplo n.º 15
0
 public static SoftFluent.Samples.GED.Document LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     SoftFluent.Samples.GED.Document document;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     document = SoftFluent.Samples.GED.Document.Load(var);
     return(document);
 }
Ejemplo n.º 16
0
 public static SoftFluent.Samples.StoreEnumAsText.Sample LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     SoftFluent.Samples.StoreEnumAsText.Sample sample;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     sample = SoftFluent.Samples.StoreEnumAsText.Sample.Load(var);
     return(sample);
 }
Ejemplo n.º 17
0
 public static ModelCodeFluent.Identity.UserLogin LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     ModelCodeFluent.Identity.UserLogin userLogin;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     userLogin = ModelCodeFluent.Identity.UserLogin.Load(var);
     return(userLogin);
 }
Ejemplo n.º 18
0
    private static T GetProperty <T>(IActiveScriptProperty prop, int index, T defaultValue)
    {
        object value;

        if (prop.GetProperty(index, IntPtr.Zero, out value) != 0)
        {
            return(defaultValue);
        }

        return(ConvertUtilities.ChangeType(value, defaultValue));
    }
Ejemplo n.º 19
0
 public static SoftFluent.Samples.AspNetIdentity2.UserClaim LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     SoftFluent.Samples.AspNetIdentity2.UserClaim userClaim;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     userClaim = SoftFluent.Samples.AspNetIdentity2.UserClaim.Load(var);
     return(userClaim);
 }
Ejemplo n.º 20
0
 public static SoftFluent.SqlServerInMemory.Customer LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     SoftFluent.SqlServerInMemory.Customer customer;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     customer = SoftFluent.SqlServerInMemory.Customer.Load(var);
     return(customer);
 }
Ejemplo n.º 21
0
 public static SoftFluent.Samples.RedisCache.Product LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     SoftFluent.Samples.RedisCache.Product product;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     product = SoftFluent.Samples.RedisCache.Product.Load(var);
     return(product);
 }
Ejemplo n.º 22
0
 public static SoftFluent.Samples.AzureCache.Category LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     SoftFluent.Samples.AzureCache.Category category;
     System.Guid var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     category = SoftFluent.Samples.AzureCache.Category.Load(var);
     return(category);
 }
Ejemplo n.º 23
0
 public static DigitalPicnik.List LoadByEntityKey(string key)
 {
     if ((key == string.Empty))
     {
         return(null);
     }
     DigitalPicnik.List list;
     System.Guid        var = ((System.Guid)(ConvertUtilities.ChangeType(key, typeof(System.Guid), CodeFluentPersistence.DefaultGuidValue)));
     list = DigitalPicnik.List.Load(var);
     return(list);
 }
        private FilterFunctions GetFilterFunction(EnumerationValue enumValue)
        {
            var op = enumValue.GetAttributeValue("filterFunction", NamespaceUri, FilterFunctions.None);

            if (op == FilterFunctions.None)
            {
                op = ConvertUtilities.ChangeType(enumValue.Name, FilterFunctions.None);
            }

            return(op);
        }
Ejemplo n.º 25
0
        public static SoftFluent.Json.NET.Publication LoadByEntityKey(string key)
        {
            if ((key == string.Empty))
            {
                return(null);
            }
            SoftFluent.Json.NET.Publication publication;
            int var = ((int)(ConvertUtilities.ChangeType(key, typeof(int), -1)));

            publication = SoftFluent.Json.NET.Publication.Load(var);
            return(publication);
        }
Ejemplo n.º 26
0
        public static SoftFluent.Json.NET.Support LoadByEntityKey(string key)
        {
            if ((key == string.Empty))
            {
                return(null);
            }
            SoftFluent.Json.NET.Support support;
            int var = ((int)(ConvertUtilities.ChangeType(key, typeof(int), -1)));

            support = SoftFluent.Json.NET.Support.Load(var);
            return(support);
        }
        public static ContactManager.ContactSource LoadByEntityKey(string key)
        {
            if ((key == string.Empty))
            {
                return(null);
            }
            ContactManager.ContactSource contactSource;
            int var = ((int)(ConvertUtilities.ChangeType(key, typeof(int), -1)));

            contactSource = ContactManager.ContactSource.Load(var);
            return(contactSource);
        }
Ejemplo n.º 28
0
        public static ContactManager.Address LoadByEntityKey(string key)
        {
            if ((key == string.Empty))
            {
                return(null);
            }
            ContactManager.Address address;
            int var = ((int)(ConvertUtilities.ChangeType(key, typeof(int), -1)));

            address = ContactManager.Address.Load(var);
            return(address);
        }
Ejemplo n.º 29
0
        public static SoftFluent.Json.NET.Customer LoadByEntityKey(string key)
        {
            if ((key == string.Empty))
            {
                return(null);
            }
            SoftFluent.Json.NET.Customer customer;
            int var = ((int)(ConvertUtilities.ChangeType(key, typeof(int), -1)));

            customer = SoftFluent.Json.NET.Customer.Load(var);
            return(customer);
        }
Ejemplo n.º 30
0
        public static ContactManager.User LoadByEntityKey(string key)
        {
            if ((key == string.Empty))
            {
                return(null);
            }
            ContactManager.User user;
            int var = ((int)(ConvertUtilities.ChangeType(key, typeof(int), -1)));

            user = ContactManager.User.Load(var);
            return(user);
        }