Beispiel #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            IPerimeter perimeter = null;
            double     result    = 0.0;

            perimeter = new SquarePerimeter(5.0);
            result    = perimeter.GetPerimeter();
            Console.WriteLine(result);

            perimeter = new RectanglePerimeter(5.0, 2.0);
            result    = perimeter.GetPerimeter();
            Console.WriteLine(result);

            perimeter = new TrianglePerimeter(5.0, 2.0, 10.0);
            result    = perimeter.GetPerimeter();
            Console.WriteLine(result);

            perimeter = new RightTrianglePerimeter(5.0, 2.0);
            result    = perimeter.GetPerimeter();
            Console.WriteLine(result);

            perimeter = new CirclePerimeter(5.0);
            result    = perimeter.GetPerimeter();
            Console.WriteLine(result);
        }
        public BaseClientFactory(
            Func <Type, IPerimeter> epcFactory,
            Func <string, string, T> serviceFactory,
            Func <string, string, IEndPointValidator> validatorFactory,
            EndPointCache endPointCache,
            EndPointContext endPointContext,
            Action <string> logger)
        {
            this.epcFactory       = epcFactory;
            this.serviceFactory   = serviceFactory;
            this.validatorFactory = validatorFactory;
            this.endPointCache    = endPointCache;
            this.endPointContext  = endPointContext;
            this.logger           = logger;

            perimeter = epcFactory(typeof(T));

            if (perimeter == null)
            {
                throw new Exception($"A Perimeter object could not be resolved for type {typeof(T).Name}.  A possible reason for this error is that type {typeof(T).Name} was not registered with a specific API_Name.", null);
            }

            if (perimeter.EndPoints == null || !perimeter.EndPoints.Any())
            {
                throw new Exception($"A Perimeter object with an API_Name of {perimeter.API_Name} was resolved for type {typeof(T).Name},  however the EndPointConfigurationItems collection is null or contains no entries.", null);
            }
        }
Beispiel #3
0
        public static IPerimeter ResolvePerimeter(this ResolutionHelper helper, Type typ)
        {
            IPerimeter result = null;

            result = helper.cxt.ResolveOptionalKeyed <IPerimeter>(typ);

            if (result == null)
            {
                throw new ComponentNotRegisteredException($"Interface { typ.Name } has not been registered.  Use RegistrationHelper to register { typ.Name } with one or more implementations, EndPointConfiguration, and API names.");
            }

            return(result);
        }
Beispiel #4
0
 public AdaptiveClient(ILifetimeScope container, Func <Type, IPerimeter> epcFactory, EndPointCache endPointCache)
 {
     this.container       = container;
     perimeter            = epcFactory(typeof(T));
     this.endPointContext = endPointCache;
 }
 public void Log(double perimeter, string type, IPerimeter shape)
 {
     Console.WriteLine(DateTime.Now + type + "method for " + shape + " is called : " + perimeter);
 }
Beispiel #6
0
 static void PrintPerimeter(IPerimeter item)
 {
     Console.WriteLine("The perimeter is {0}", item.GetPerimeter());
 }