Esempio n. 1
0
        public override CultureInfo GetUserResourceCultureInfo(ValueForUICulture locValue)
        {
            CultureInfo cultureInfo = null;

            if (locValue.CultureId.HasValue)
            {
                cultureInfo = new CultureInfo(locValue.CultureId.Value);
            }
            else if (!string.IsNullOrEmpty(locValue.CultureName))
            {
                cultureInfo = new CultureInfo(locValue.CultureName);
            }
            else
            {
                throw new SPMeta2Exception(string.Format("Either CultureId or CultureName should be defined"));
            }

            return(cultureInfo);
        }
        public override void ProcessUserResource(object parentObject, object userResource, ValueForUICulture locValue)
        {
            var typedUserResource = userResource as ClientObject;

            if (typedUserResource == null)
            {
                throw new SPMeta2Exception("userResource should be an instance of ClientObject");
            }

            if (typedUserResource.GetType().Name.ToUpper() != "UserResource".ToUpper())
            {
                throw new SPMeta2Exception("userResource should be an instance of UserResource");
            }

            var context     = typedUserResource.Context;
            var cultureInfo = GetUserResourceCultureInfo(locValue);

            var query = new ClientActionInvokeMethod(typedUserResource, "SetValueForUICulture", new object[]
            {
                cultureInfo.Name,
                locValue.Value,
            });

            context.AddQuery(query);
        }
Esempio n. 3
0
        public override void ProcessUserResource(object parentObject, object userResource, ValueForUICulture locValue)
        {
            var typedResource = userResource.WithAssertAndCast <SPUserResource>("userResource", value => value.RequireNotNull());

            var cultureInfo = GetUserResourceCultureInfo(locValue);

            typedResource.SetValueForUICulture(cultureInfo, locValue.Value);
            typedResource.Update();
        }
Esempio n. 4
0
 public abstract void ProcessUserResource(object parentObject, object userResource, ValueForUICulture locValue);
Esempio n. 5
0
        public override void ProcessUserResource(object parentObject, object userResource, ValueForUICulture locValue)
        {
            var typedUserResource = userResource as ClientObject;

            if (typedUserResource == null)
            {
                throw new SPMeta2Exception("userResource should be an instance of ClientObject");
            }

            if (typedUserResource.GetType().Name.ToUpper() != "UserResource".ToUpper())
            {
                throw new SPMeta2Exception("userResource should be an instance of UserResource");
            }

            var context     = typedUserResource.Context;
            var cultureInfo = GetUserResourceCultureInfo(locValue);

            var clientRuntimeQueryService = ServiceContainer.Instance.GetService <ClientRuntimeQueryServiceBase>() ?? new DefaultClientRuntimeQueryService();

            clientRuntimeQueryService.InvokeMethod(typedUserResource, "SetValueForUICulture", cultureInfo.Name, locValue.Value);
        }