Beispiel #1
0
        //by nesting level and grouping key cut the full path to the directory
        public static string GetFullNameFromIndex(string key, int index)
        {
            if (key.Length == 1)
            {
                return(getFirstDir(key));
            }

            var subkeys = new List <string>();

            for (int i = 0; i < key.Length - 1; i++)
            {
                subkeys.Add(key.Substring(0, i + 1));
            }
            subkeys[0] = getFirstDir(key);

            for (int i = 0; i < subkeys.Count; i++)
            {
                if (ReservedStrings.ContainsKey(subkeys[i].ToLowerInvariant()))
                {
                    subkeys[i] = subkeys[i] + "-";
                }
            }
            if (ReservedStrings.ContainsKey(key.ToLowerInvariant()))
            {
                key = key + "-";
            }

            var separator = Path.DirectorySeparatorChar.ToString();

            var minString = string.Join(separator, subkeys.Take(index + 1).ToArray());

            return(Path.Combine(minString, key));
        }
Beispiel #2
0
 public static string GetFolderForMapname(string mapName)
 {
     if (ReservedStrings.ContainsKey(mapName.ToLowerInvariant()))
     {
         mapName = mapName + "-";
     }
     return(Path.Combine(getFirstDir(mapName), mapName));
 }
Beispiel #3
0
        public static bool IsNotValid(this IDeviceRegistration deviceRegistration, object sender, IAnalyticsService analyticsService, out Error error)
        {
            if (deviceRegistration == null)
            {
                error = PushErrors.InvalidDeviceRegistration;
                analyticsService.TraceError(sender, error);
                return(true);
            }

            //if (deviceRegistration.Templates.Count == 0)
            //{
            //    error = analyticsService.TraceError(sender, PushErrors.NoTemplateProvidedOnRegistration, deviceRegistration.ToObjectDictionary());
            //    return true;
            //}

            if (string.IsNullOrEmpty(deviceRegistration.PushNotificationServiceHandle))
            {
                error = PushErrors.InvalidPnsHandle;
                analyticsService.TraceError(sender, error, deviceRegistration.ToObjectDictionary());
                return(true);
            }

            if (deviceRegistration.Platform == null || string.IsNullOrEmpty(deviceRegistration.Platform.Value) ||
                deviceRegistration.Platform.Value != RuntimePlatform.iOS.Value &&
                deviceRegistration.Platform.Value != RuntimePlatform.Android.Value &&
                deviceRegistration.Platform.Value != RuntimePlatform.UWP.Value)
            {
                error = PushErrors.InvalidPlatform;
                analyticsService.TraceError(sender, error, deviceRegistration.ToObjectDictionary());
                return(true);
            }

            if (string.IsNullOrEmpty(deviceRegistration.DeviceIdentifier))
            {
                error = PushErrors.MissingDeviceIdentifier;
                analyticsService.TraceError(sender, error, deviceRegistration.ToObjectDictionary());
                return(true);
            }

            if (string.IsNullOrEmpty(deviceRegistration.UserId))
            {
                error = PushErrors.MissingUserId;
                analyticsService.TraceError(sender, error, deviceRegistration.ToObjectDictionary());
                return(true);
            }

            foreach (var template in deviceRegistration.Templates)
            {
                foreach (var templateDataProperty in template.DataProperties)
                {
                    var reservedStrings = ReservedStrings.GetForPlatform(deviceRegistration.Platform);
                    if (reservedStrings.Contains(templateDataProperty))
                    {
                        error = PushErrors.ReservedString(templateDataProperty);
                        analyticsService.TraceError(sender, error, deviceRegistration.ToObjectDictionary());
                        return(true);
                    }
                }
            }

            error = Error.None;
            return(false);
        }